home *** CD-ROM | disk | FTP | other *** search
/ The ZX Files 3 / ZX Files 3 (Disk 3 of 3).adf / 119 / 119
Text File  |  1978-01-28  |  127KB  |  3,263 lines

  1. HOW TO HACK on the ZX Spectrum
  2.  
  3. A complete guide to creating POKEs on the Spectrum, featuring
  4. full examples. Devised and written by Richard P Swann
  5.  
  6. NB : This document was originally intended to be printed in
  7. Your Sinclair magazine. It is split into "pages" of 58 lines.
  8.  
  9.  
  10. CONTENTS
  11.  
  12. WHAT YOU WILL NEED...........................Page 1
  13.  
  14. THE BASIC IDEA...............................Page 2
  15.     Getting started with hacking
  16.  
  17. CONVENTIONAL HACKING TECHNIQUES..............Page 8
  18.     Forwards trace and backwards trace
  19.  
  20. EASY LOADING SYSTEMS.........................Page 11
  21.     Headerless loaders, turboloads and compression
  22.  
  23. DECRYPTERS...................................Page 18
  24.     Single decrypter loading systems
  25.  
  26. ADVANCED HACKING METHODS.....................Page 24
  27.     Stack trace and interrupt trace
  28.  
  29. COMMERCIAL PROTECTION SYSTEMS................Page 26
  30.     Bleepload, Ultimate loader, Mikro Gen Loader,
  31.     Powerload, Search Loader, Paul Owens Protection
  32.     System, Speedlocks
  33.  
  34. EPILOGUE.....................................Page 59
  35.     Scrolling credits etc. etc.
  36.  
  37. GLOSSARY AND INDEX...........................Page 60
  38.  
  39. WHAT YOU WILL NEED
  40.  
  41. If you want to use this book successfully, you will need the
  42. following:
  43.  
  44. * An understanding of Spectrum BASIC. If you are total beginner,
  45. you will almost certainly find this book too complicated, and
  46. hence useless to you. If you can understand most of the Spectrum
  47. manual, then you should be all right. If you don't understand a
  48. word of the section on using +3 DOS in machine code in the +3
  49. manual, don't worry, 'cause I don't either!
  50.  
  51. * A disassembler or a monitor program. You can, in theory, hack
  52. anything without one of these, but in practice, it would be
  53. impossible for a beginner, and next to impossible for someone
  54. experienced. My personal choice is Hisoft's DEVPAC, but if you
  55. have the programs STK and 007 Disassembler (which were on the
  56. covertapes of YS no.75 and no.77), that'll do fine for this book.
  57.  
  58. * Some games to hack. Obviously business software is out of the
  59. window because it's illegal to hack it, and you don't need to
  60. anyway. Strategy and adventure games are pretty unlikely to
  61. demand a POKE (although it's possible, and I'll show you how I
  62. hacked an adventure later on), so you're left with arcade and
  63. arcade adventure games. Most of the time you'll want to find
  64. infinite lives and/or energy, but there are always exceptions.
  65. This book concentrates on games that you're likely to have, which
  66. are games which have been on magazine covertapes, or bestsellers.
  67.  
  68. * Patience and determination. This is the most important thing of
  69. all. Finding POKEs is challenging without any knowledge of how
  70. the program works, or even a knowledge of the language it's
  71. written in! So be prepared to do some serious THINKING!
  72.  
  73. * A Multiface or other "magic box" device. This is not essential,
  74. but it is extremely useful, and a few sections in this book
  75. require you to have one (but as few as possible, I might point
  76. out!)
  77.  
  78. PART ONE - The Basic Idea
  79.  
  80.  Before we get down to some serious hacking, it will be a good
  81. idea to know what we are looking for. Okay, I know that some of
  82. you may think that this is pointless, but if you don't know what
  83. you're aiming at, you'll never get anywhere.
  84.  Basically, we are going to examine a program, and change it so
  85. that certain instructions are altered so that the game becomes
  86. more easier to the user. This may be in the form of infinite
  87. lives, infinite energy, immunity, infinite bullets etc.
  88.  The only way we can hope to do this is to understand what is
  89. going on in the game. And because most games are written in
  90. machine code, we're going to have to understand that as well.
  91. Please don't be put off by the thought of learning a new
  92. language; in fact you need know very little machine code
  93. knowledge to hack most games.
  94.  
  95.  To start with, we'll just look at infinite lives. Lives are
  96. normally a small number, between 3 and 9 (although some games may
  97. have more), and the common thing with all games that have lives
  98. is that somewhere in the game, the amount of lives are set as a
  99. definite number, and somewhere else, the amount of lives goes
  100. down by one. In order to get infinite lives, we would have to
  101. remove the command in the program which decreased a player's
  102. lives.
  103.  You probably have and idea about how a lives system would work
  104. in BASIC. Say if, for argument's sake, a BASIC game had three
  105. lives, you would expect to see something like...
  106.  
  107. 100 LET LIVES=3
  108.  
  109. ...contained in the program. Then, a bit further on, you'd expect
  110. to see...
  111.  
  112. 500 LET LIVES=LIVES-1
  113.  
  114.  In order to get infinite lives, we would simply remove line 500
  115. altogether and RUN the program.
  116.  
  117.  A similar idea appears in machine code, but the way it's done is
  118. slightly different.
  119.  For starters, machine code doesn't have any variables! You might
  120. therefore wonder how on earth the computer can store anything. In
  121. actual fact, the computer can store information anywhere in RAM,
  122. as you may well know, and this is exactly what happens in machine
  123. code.
  124.  In Chapter 24 ("The Memory") of the Spectrum manual, there's a
  125. detailed description of the Spectrum's memory. The best way to
  126. visualise the memory, I think, is to imagine 65,536 boxes, each
  127. one containing a piece of paper with a number from 0 to 255
  128. written on it.
  129.  Therefore, it is no problem for a computer to store the number
  130. of lives in machine code, since it can just put it as a byte in a
  131. memory location, leave it there, and come back to it later.
  132.  You should be aware that in machine code, commands are also
  133. stored in memory locations as bytes; so if you get commands and
  134. data mixed up in memory, the computer could easily try and
  135. execute the data, thinking it's a command, and trying to execute
  136. it. Unlike BASIC, there are no errors in machine code, and the
  137. computer can execute anything it finds, so in this case you will
  138. get a crash. So most programs keep program data and program
  139. commands separately.
  140.  Anyway, in order to store three lives in machine code, we'd put
  141. the number 3 in a memory location. Unfortunately, we can't do
  142. this straight away in machine code, and we can only do it by
  143. using what are called registers.
  144.  Registers store information in the same way as memory locations.
  145. They are bit more versatile though, as you can perform
  146. calculations with them. All the same, they are not the same as
  147. variables in BASIC, and are more like a pair of hands used for
  148. counting.
  149.  The main register we'll look at for now is the A register
  150. (sometimes called the accumulator), which can store a single
  151. byte and have sums done to it.
  152.  What we would do to store the number three in a memory location
  153. is to put the number 3 into the A register, then put the contents
  154. of the A register (which are of course, 3) into a memory
  155. location.
  156.  The actual way of writing this in machine code is:
  157.  
  158. LD A,3
  159. LD (#8000),A
  160.  
  161.  Actually, strictly speaking, the above isn't machine code at all!
  162. Machine code as the computer sees it is, as I explained earlier,
  163. consists of many bytes in memory, which are pretty meaningless to
  164. humans. So some people invented assembly language (which is what
  165. the above is), where each instruction carried out by the computer
  166. is given a name (called a mnemonic).
  167.  The above program features one command used in two different
  168. ways. The command is LD, which is pronounced "load". This has
  169. nothing at all to do with loading a program from tape. It
  170. basically is a transfer of information from one place to another.
  171. The comma in the instructions is read as "with", so the whole
  172. instruction is read as "Load A with 3". It now seems obvious that
  173. this instruction is putting the number 3 into the A register.
  174.  The second command is also LD, but the way its used is slightly
  175. different. The brackets mean "the contents of", so the whole
  176. instruction is read as "load the contents of #8000 with A".
  177. (Think of a bracket as a byte in memory, where everything in the
  178. bracket is part of that byte) Therefore, this instruction would
  179. make the computer take whatever value is in the A register, and
  180. store it in memory location #8000 (of course, it could be any
  181. other memory location as long as it is unused).
  182.  So the overall result of the two commands (normally called
  183. operations) would be to put the number 3 in memory location
  184. #8000.
  185.  
  186.  Congratulations! You've just learned the first way to hack.
  187. Clearly, if in a real program, we found these operations, we
  188. could change the LD A,3 to something like LD A,100 to get 100
  189. lives!
  190.  Before we can do any "real" hacking, I'd better discuss how
  191. "real" machine code is written.
  192.  Every machine code instruction contains and opcode, and some
  193. instructions need an operand. An opcode is simply the instruction
  194. the computer is going to do. Every number from 0 to #FF corresponds
  195. with a specific opcode. You can find a complete list of opcodes
  196. in Appendix A of your Spectrum manual.
  197.  The operand is used whenever there is ambiguity over something.
  198. If you look in Appendix A of the Spectrum manual, you will see
  199. that the opcode #3E is "LD A,n". "n" in this case can mean any
  200. single byte number ie: a number from 0 to 255. But it's possible
  201. to put any number within this range eg: LD A,3 or LD A,#40 or LD
  202. A,#80 etc. The computer has to somehow know what data it is
  203. dealing with, and this is where the operand comes in. In machine
  204. code, whenever the computer comes across the opcode #3E, it
  205. looks at the byte after the opcode, and assumes it's the data
  206. needed. So, if the computer came across the bytes #3E and #40 in
  207. succession, it would put the value #40 in the A register. In this
  208. example, #3E is the opcode, while #40 is the operand. After
  209. executing the instruction, the computer goes to the byte after
  210. the operand, and starts running code from there.
  211.  In the second instruction of our example, the opcode is #32, ie:
  212. "LD (NN),A". The ambiguity is in the address where we are going
  213. to store the value of the A register. In this case, the operand
  214. takes up two bytes, hence the "NN", which again comes after the
  215. opcode. You should note that this is an address in memory, and is
  216. always referred to as two bytes. So you might expect the machine
  217. code equivalent of LD (#8000),A to be #32 #80 #00. Except it
  218. isn't! For some odd reason, in machine code, all two byte
  219. operands are written the wrong way round, so the actual machine
  220. code equivalent of LD (#8000),A is #32 #00 #80. There is no hard
  221. and fast reason why, it's just vitally important that you
  222. remember this.
  223.  
  224.  In short, the program of the previous page is written as...
  225.  
  226. #3E #03 #32 #00 #80
  227.  
  228. ...which takes up five bytes.
  229.  Not all instructions require operands. For example, DEC A (short
  230. for "decrease A", which subtracts one from the A register) has no
  231. ambiguity at all. There is only one way to decrease the value in
  232. the A register, so the instruction only takes up one byte, in
  233. this case #3D. No operands are needed.
  234.  
  235.  Right, time for your first bit of hacking! From what we've
  236. discussed above, we want to find, somewhere in the game's code, a
  237. set of instructions which put the number of lives into a byte in
  238. memory. So if the game had three lives, we could expect to see
  239. the bytes...
  240.  
  241. #3E #03 #32
  242.  
  243. ...unfortunately, we don't know where in memory the number of
  244. lives is going to go, so we can't work out the operands for the
  245. second instruction (#32). But in fact, we don't need to, for if
  246. we find the above sequence of bytes in a program, we can simply
  247. examine the two bytes after this sequence to find out where in
  248. memory the number is being put.
  249.  
  250.  So let's put this into practice and hack an actual game. For
  251. convenience I've chosen Sweevo's World, which featured on a YS
  252. Covertape Issue 60 December 1990. I would have chosen a more
  253. recent game, but they all have some form of protection on them.
  254. Besides, obtaining infinite lives is relatively easy.
  255.  Getting the game in memory without it running is easy. If you've
  256. typed out a fair few POKEs in your time, this will be no problem.
  257. Just MERGE the BASIC loader and put a STOP statement before the
  258. RANDOMIZE USR statement. Then RUN the program and wait for it to
  259. load, until the OK message appears.
  260.  Now we have the game in memory, we can load STK and examine it.
  261. You have to be a bit careful here, because STK occupies 6K of the
  262. Spectrum's memory. Although it can be anywhere in memory, it
  263. possible to overwrite the all-important lives code in the game
  264. with STK, so we have to be careful. The best places to put STK are
  265. in the graphics, map or sound data. There's no easy way to tell
  266. where this is, so you'll have to try pot luck. But it helps if
  267. you know where the game loads to, so load up STK at any address,
  268. and press J and then Caps+9 to read in a header a couple of
  269. times. Then read the headers of the three blocks of code after
  270. the BASIC. They are:
  271.  
  272. Bytes: S 4000,1B00
  273. Bytes: M FB90,043D
  274. Bytes: P 60E0,82B0
  275.  
  276. The first block is the loading screen. The second block is in
  277. actual fact the game's music (but you wouldn't be expected to
  278. know this), and the third block is the actual game itself.
  279. Therefore, we can put STK anywhere above (60E0+82B0)=E390. For
  280. argument's sake, let's put it at EA60, which is 60000 decimal.
  281. When we've finished hacking, we can reload "Bytes: M" and run the
  282. program. Load up STK (after having stopped the BASIC and returned
  283. with a STOP statement) at address 60000.
  284.  
  285.  Now at last, some hacking. Bearing in mind that you start the
  286. game with five lives. Press Q to search for a byte. Enter the
  287. address we want to start searching at as 60E0, because that's the
  288. start of the game. Now type in the following:
  289. #3E #05 #32
  290. These are the search bytes we described on the previous page.
  291. Keep pressing N for "next" until all of the memory has been
  292. searched. You will get the following addresses: 905C and EEDC.
  293. You can ignore the one at EEDC, because it's in the middle of STK
  294. and outside the main game code, so that leaves just the one at
  295. 905C. Press E for edit and type #905C. You'll see the following
  296. bytes:
  297.  
  298. 3E 05 32 1A 61
  299.  
  300.  So this tells us that the computer puts the number five in box
  301. number 611A (remember that 2 byte numbers are reversed!) Now to
  302. hack the game, we simply change the number 5 at 905D to any
  303. number of lives we want (the maximum is #FF).
  304. Now, get out of STK, reload the "Bytes: M" file and RANDOMIZE USR
  305. 24800 (the original command in the BASIC), and hey presto - you
  306. will have whatever amount of lives you wanted!
  307.  
  308.  All that remains to do is to write a proper hack for it. 905D is
  309. 36957 in decimal, so your hack would be something like "MERGE the
  310. BASIC loader, and insert POKE 36957,n before the RANDOMIZE USR
  311. statement, where 'n' is the number of lives."
  312.  And it's as simple as that. If you can understand what we've
  313. done so far, you're doing well, so stick at it.
  314.  Any unprotected game like Sweevo's World is hacked in the same
  315. way, except you will probably have to reload STK to a different
  316. address, and you may find that in your search for #3e <lives>
  317. #32, you may come across several locations in memory outside STK
  318. that have this pattern. In this case, you'll have to use trial
  319. and error to work out which one holds the number of lives.
  320.  
  321.  It is, of course, perfectly possible for you now to find 'number
  322. of lives' POKEs for any unprotected game under the sun, and in
  323. the early days of Spectrums ('82-'84), this would have been
  324. perfectly adequate. Of course, what your really need is the real
  325. nitty gritty - INFINITE lives. This is done by taking things just
  326. a step further.
  327.  What you basically need to do is find out which memory location
  328. the number of lives are being put in. Then you need to search for
  329. parts of the program which put the value of that memory location
  330. in a register, subtract one from it, and put the new value in the
  331. register back. Then you have to rewrite the code slightly so that
  332. the computer "forgets" to decrease the value in the register, and
  333. simply puts the old value back in again.
  334.  
  335.  Coming back to Sweevo's World, we already know that the number
  336. of lives are stored at memory location 611A. I normally refer to
  337. this memory location as the "lives store" for obvious reasons.
  338. All we have to do is search for all the occurrences of the
  339. address of the lives store. So, search for #1A,#61, and you will
  340. find it referred to at the following addresses:
  341.  
  342. 779B   8160   81A9   905F   EEDC
  343.  
  344.  You can ignore the one at EEDC because it's in STK, but you can
  345. also ignore the one at 905F, since that's part of the lives
  346. setting routine we discussed earlier. So the routine to decrease
  347. the number of lives must lie at one of the other locations.
  348.  You should note, that any instruction that involves the lives
  349. store will begin at the byte before, because 1A and 61 are two
  350. byte operands (see page 3 for more about operands).
  351.  
  352.  So for starters, press E to edit an address and type in #779A.
  353. You'll see the following:
  354.  
  355. 779A - 3A 1A 61 C3 61 99
  356.  
  357.  If you look up 3A in Appendix A of your Spectrum manual, you'll
  358. see it corresponds to the instruction LD A,(NN). This is simply a
  359. reverse of the LD (NN),A instruction, in that the value of a
  360. memory location is put into the A register. This is important,
  361. because subtraction of any sort can only be done in a register,
  362. and usually in the A register.
  363.  After the computer has executed the three byte instruction 3A 1A
  364. 61 (which is LD A,(611A in mnemonics), it executes the
  365. instruction C3. If you look up C3 in Appendix A of your Spectrum
  366. manual, you'll see it corresponds to the instruction JP. JP is
  367. short for "jump", and is in a sense like GOTO in BASIC. What the
  368. computer does is to jump to a location in memory. As you can see,
  369. there is ambiguity as to where it is going to jump, so we need a
  370. two byte operand. Like the ones me have met before, the bytes are
  371. written the wrong way round. So C3 61 99 means JP 9961. In this
  372. case, the computer would go to address 9961, and start executing
  373. code from there.
  374.  It is possible that the code to decrease the number of lives is
  375. at 9961, but is unlikely, because it pointless to have to jump to
  376. a completely different area of memory. So we'll leave this part
  377. of memory, and go onto the next instruction, at 8160. Press EDIT
  378. to leave the editing procedure, and edit address 815F. You'll see
  379. the following:
  380.  
  381. 815F - 21 1A 61 35
  382.  
  383.  21 is the instruction LD HL,NN. HL is another register like A,
  384. but its main difference is that it can store two bytes at once.
  385. So LD HL,NN requires a two byte operand, whereas LD A,N only
  386. requires one. So here the instruction 21 1A 61 means LD HL,611A.
  387. The next instruction, 35 doesn't need any operands, and is the
  388. instruction we've been looking for. 35 means DEC (HL). You've
  389. already come across brackets meaning "the contents of", so as you
  390. might have guessed, DEC (HL) decreases whatever is at the memory
  391. location with the same number as HL by one. In this case, we know
  392. that HL is 611A, because we've just set it in the last
  393. instruction. So DEC (HL) will decrease the value of whatever is
  394. in memory location 611A by one in this case.
  395.  But we already know that the number of lives is stored at memory
  396. location 611A. So clearly DEC (HL) is going to decrease the
  397. number of lives by one!
  398.  What we need to do to make an infinite lives POKE is to somehow
  399. overwrite the DEC (HL) so that the computer doesn't decrease the
  400. number of lives. There are two things that can be done. Firstly
  401. the address containing DEC (HL) can be replaced by 0. The number
  402. 0 relates to an instruction called NOP. NOP is short for "No
  403. operand", and in short means absolutely nothing! When the
  404. computer encounters the instruction NOP, it will do nothing and
  405. execute the next instruction. So if we overwrite DEC (HL) with
  406. NOP, the computer won't decrease the number of lives, but do
  407. nothing instead. The vast majority of POKEs have the format POKE
  408. address,0 for the reasons described above.
  409.  If you run Sweevo's World changing the DEC (HL) to NOP, you'll
  410. find you only get one life instead of five! In this case, you
  411. should overwrite the DEC (HL) with OR (HL). OR (HL) is a single
  412. byte instruction, B6. Don't worry about what it does, because it
  413. isn't important. What is important is to remember to do this if
  414. you only get one life.
  415.  Rerun Sweevo's World, replacing the DEC (HL) with OR (HL), and
  416. you'll have your infinite lives! The DEC (HL) is at address 8162,
  417. which is 33122 decimal, while B6 is 182 decimal, so the POKE
  418. would go something like "MERGE the loader, and put POKE 33122,182
  419. before the RANDOMIZE USR statement, RUN the program and restart
  420. the tape."
  421.  Now we've covered the rudiments of machine code involved in
  422. hacking, we can look at more detailed ways of finding POKEs.
  423.  
  424. PART 2 - Conventional Hacking Techniques
  425.  
  426.  By now, you should have an idea of how simple machine code
  427. works. Now we're going to look at the usual techniques of
  428. hacking. There are five techniques, which are called Forwards
  429. Trace, Backwards Trace, Stack Trace and Interrupt Trace, in that
  430. order of difficulty. Of these, Forwards Trace and Backwards trace
  431. are the only techniques you can use without a Multiface, and are
  432. the most reliable methods. You should only really have to use the
  433. others in exceptional circumstances, which are, on the whole,
  434. games which don't have a lives system or a GAME OVER message.
  435. Very few games use unusual routines, since it's just a hindrance
  436. to the programmer.
  437.  
  438.  We'll start with Forwards Trace. You've already had a go at this
  439. from the last part, so hopefully it won't be too hard to
  440. understand. Then we'll look at the backwards trace, followed by
  441. some practical examples.
  442.  
  443. FORWARDS TRACE:
  444.  
  445.  For the forwards trace, you start with the lives initialisation
  446. routine, and then work forwards from there.
  447.  The first thing you need to do is to find where the number of
  448. lives are defined. We've already seen how numbers are put into
  449. memory locations, and this is exactly what happens in most games.
  450.  (From now on, all the machine code programs discussed here will
  451. be written as hexadecimal bytes, and as mnemonics.)
  452.  
  453. 3E XX         LD A,XX (where XX is the number of lives)
  454. 32 XX XX      LD (XXXX),A (where XXXX is a memory location,
  455.                            which we will refer to as the
  456.                            "lives store".)
  457.  
  458.  You have already come across these instructions, but just to
  459. resume, the number of lives is put in the A register, which in
  460. turn is put in the lives store, the overall result being the
  461. number of lives being put in the lives store.
  462.  
  463.  To find this, use the search function on your disassembler
  464. (QUEST 16384 on STK), and search for 3E <number of lives>. So
  465. if you had five lives, you'd search for 3E 05. You may find that
  466. this instruction occurs a few times, but you will probably find
  467. that only one actually puts the value of A in a memory location
  468. straight away. If there appear to be two occurrences where the
  469. number of lives is put into a memory location, then you may have
  470. to test all of them. You can, in general, rule out memory locations
  471. in which the number of lives is put in twice.
  472.  If you want to confirm you've found the lives store, you need
  473. a Multiface. Load the game up, and while playing the game, alter
  474. the value in what you think is the lives store. If the number
  475. of lives varies, you've found the lives store. If not, try
  476. another possible location. If you can't find any memory location
  477. which looks like a lives store, you won't be able to forwards
  478. trace, I'm afraid, in which case you should try the backwards
  479. trace instead.
  480.  Once you've found the lives store, you'll have to search for
  481. occurrences of it. You are basically looking for code which takes
  482. the value out of the lives store and puts it in a register
  483. (normally the A register), decreases the number by one, and puts
  484. the new result back in the lives store. To get infinite lives, you
  485.  have to overwrite the decrement instruction with a blank
  486. instruction so that the number of lives is left intact.
  487.  The code you want normally takes one of two formats:
  488.  
  489. 1st type:
  490. 3A XX XX     LD A,(XXXX) where XXXX is the lives store
  491. 3D           DEC A (we want to remove this)
  492. 32 XX XX     LD (XXXX),A (putting the new value in the lives store)
  493.  
  494. 2nd type:
  495. 21 XX XX     LD HL,XXXX where XXXX is the lives store
  496. 35           DEC (HL)   We want to remove this
  497.  
  498.  You may find that there are other instructions between these.
  499. Don't worry about what they mean, just ignore them.
  500.  
  501.  In order to remove the decrement instruction, we have to do
  502. one of two things. The most common is to replace the DEC A or
  503. DEC (HL) with a NOP (code 00). If this gives you only one life,
  504. replace the DEC A with OR A (code B7), or replace the DEC (HL)
  505. with OR (HL) (code B6). Don't worry why!
  506.  
  507. BACKWARDS TRACE:
  508.  
  509.  Also known as "backtracking", a backwards trace starts from the
  510. GAME OVER message, and goes back from there to the lives routine.
  511. It is normally used when a forwards trace does not work or is
  512. unsuitable (eg: when finding infinite energy), the easiest
  513. alternative is to use a backwards trace.
  514.  
  515.  The first thing you need to do is to find out what message is
  516. printed on the screen when you die. Nine times out of ten it's
  517. "GAME OVER", but there are exceptions.
  518.  For GAME OVER you have to search for the following bytes :
  519. 47 41 4D 45 32 4F 56 45 52. This is GAME OVER in ASCII (look up
  520. the codes in Appendix A of the Spectrum manual if you like).
  521. Sometimes, you may not find it, in which case just search for
  522. 47 41 4D 45 (GAME in ASCII). If that search fails, then the
  523. GAME OVER text is not in an ASCII format (this is rare, because
  524. printing routines are considerably smaller when ASCII is used),
  525. and you can't do a backwards trace.
  526.  
  527.  Once you've found the GAME OVER message, you need to find out
  528. which part of the program refers to it. Normally, a print
  529. routine will load a register with the address of the GAME OVER
  530. routine, then print it. One possible register is HL (as we have
  531. met before), but also two other registers called BC and DE. Normally,
  532. all of these three registers are referred to as "register pairs",
  533. because they are two registers, each the same size as the A
  534. register, working together, so they can address all of the memory.
  535. You want to look for the following:
  536.  
  537. 01 XX XX     LD BC,XXXX (where XXXX is the address of the GAME
  538.                                                  OVER MESSAGE)
  539.  
  540. 11 XX XX     LD DE,XXXX (as above)
  541.  
  542. 21 XX XX     LD HL,XXXX (as above)
  543.  
  544. (Remember that XXXX will be written "backwards" in the game's
  545. machine code!)
  546.  
  547.  You should only find one occurrence of any of the above
  548. instructions. If you can't find any, repeat the search but take
  549. one away from the address the GAME OVER text is. (This is because
  550. sometimes there are Spectrum ASCII control codes such as 16 XX
  551. for PAPER XX before the actual text, and these are referred
  552. to as the start of the message). If that doesn't work, repeat the
  553. search taking one away again. Keep doing this and you'll soon
  554. find one of the above instructions.
  555.  
  556.  When you've found the instruction, note down where it occurs.
  557. The part of the code you are now in is part of the GAME OVER
  558. printing routine. What you now need to do is go back through
  559. the code until you find either the code C3 XX XX (which is JP
  560. XXXX), or C9 (which is RET, which behaves exactly the same way
  561. as RETURN in BASIC.) Alternatively, you may find a blank area
  562. of memory (00 00 00 00 00 00 etc.) The address after one of
  563. these instructions is the START of the GAME OVER routine.
  564.  
  565.  When you've found the start of the GAME OVER routine, you
  566. can find out which part of the code calls it. Then, to get a
  567. cheat, you can remove all parts of the code which branch to
  568. the GAME OVER routine. Search for the address of the start of
  569. the routine. You will probably find some of the following:
  570.  
  571. CD XX XX   CALL XXXX
  572. CC XX XX   CALL Z, XXXX
  573. C4 XX XX   CALL NZ, XXXX
  574. C3 XX XX   JP XXXX
  575. CA XX XX   JP Z,XXXX
  576. C2 XX XX   JP NZ,XXXX
  577.  
  578. ...where XXXX is the start of the game over routine. JP is
  579. similar to GOTO in BASIC, while CALL is similar to GOSUB (so that
  580. a RET instruction will return to the instruction after the call -
  581. except in some protection systems, but more about that later).To
  582. cheat, simply poke all three bytes of the instruction you find
  583. with 00 (so as to disable the CALL or JP). And there you have it!
  584.  
  585.  Using the techniques of forwards trace and backwards trace, you
  586. should be able to hack most old, unprotected games!
  587.  
  588. PART 3 - EASY LOADING SYSTEMS
  589.  
  590.  So far, you've worked out the all important basics of hacking.
  591. However, there is another, equally important facet of hacking
  592. games that you should know about.
  593.  
  594.  Few games these days are unprotected. They feature "protection
  595. systems" which prevent you from breaking into a program and
  596. fiddling about with it. The difficulty level varies, but in
  597. general they use two concepts - headerless loading and
  598. decryption.
  599.  
  600.  Before we do anything, I should point out that you're going to
  601. need a disassembler from now on. The machine code listings in
  602. this book use Devpac's notation, but 007 Disassembler's notation
  603. is almost identical, except it uses decimal instead of hex.
  604. Hopefully, you shouldn't get lost if you use
  605.  
  606.  Anyway, for now, we'll forget about decryption and
  607. concentrate of headerless loaders, since they're common to all
  608. protection systems.
  609.  
  610.  A headerless loader will look something like this:
  611.  
  612. DD 21 XX XX    LD IX,XXXX
  613. 11 XX XX       LD DE,XXXX
  614. 3E FF          LD A,#FF
  615. 37             SCF
  616. CD 56 05       CALL #0556
  617.  
  618.  ...where XX can be any number from #00 to #FF. IX is another
  619. register similar to HL, but has slightly different properties,
  620. which you don't need to worry about right now. The value put into
  621. IX is always the start address of the block to be loaded, and the
  622. value put into DE is always the length of the block to be loaded.
  623. So the routine works exactly like loading and saving bytes in
  624. BASIC.
  625.  The only differences you should ever find are that the CALL is
  626. to a different address (#0556 is the ROM loading routine, so
  627. other CALLS are to turboloaders in RAM), the LD A,#FF has some
  628. other value loaded into A instead, or is missing, or the SCF is
  629. missing. Basically, if you see DD 21 XX XX 11 XX XX in a
  630. protection system, you can be pretty sure it will be used to load
  631. something.
  632.  
  633.  Now we know how a headerless loader works, let's try and hack a
  634. real one. As an example, I've chosen Ethnipod, which was on the
  635. May 1991 YS Covertape.
  636.  
  637.  First of all, load up STK at any address (I'd suggest 32768, but
  638. you don't have to) and press Z to BLOAD in the BASIC. Then use
  639. STK to list the basic, and you'll get the following:
  640.  
  641. 10 BORDER 0: PAPER 0: INK 7: CLEAR 24999: LOAD "" CODE
  642. 65000: RANDOMIZE USR 65000
  643.  
  644. Therefore, we should type in CLEAR 24999:LOAD "" CODE 65000 and
  645. restart the tape. When the OK message appears, stop the tape,
  646. load up your disassembler, and have a look at address 65000
  647. (#FDE8). Here's a complete disassembly of the code you'll find
  648. there.
  649.  
  650. FDE8 21 00 40    LD HL,#4000
  651. FDEB 11 01 40    LD DE,#4001
  652. FDEE 01 FF 1A    LD BC,#1AFF
  653. FDF1 36 00       LD (HL),#00
  654. FDF3 ED B0       LDIR
  655.  
  656.  LDIR is a command we haven't met before, but it's easy to
  657. understand. It's a copying routine. The start address of the
  658. block you want to copy is put in HL, the length of the block you
  659. want to copy is put in BC, and the start address of the area of
  660. memory you want to copy it to is put in DE. So, in the example
  661. above, the area of memory from #4000 is copied to #4001 for #1AFF
  662. bytes. In short, this routine is overlaying each address in this
  663. area of memory with the byte of the previous address.
  664.  The LD (HL),00 means that byte #00 is put into address #4000.
  665. Therefore, the whole of the memory from #4000 to #5AFF is filled
  666. with 0. In case you didn't know, the whole of this memory is the
  667. screen memory, so this bit of code is what makes the screen black
  668. when loading the game normally. If you want, you can change the
  669. byte at #FDED to #00 to give LD DE,#0001, so the contents of the
  670. screen memory are copied into the ROM (except that they aren't
  671. because the ROM is a read-only memory and you can't write
  672. anything into it.) This will stop the screen going black. You
  673. don't actually need to do it at all, but there we go.
  674.  Continuting the disassembly:
  675.  
  676. FDF5 11 00 1B    LD DE,#1B00
  677. FDF8 DD 21 00 80 LD IX,#8000
  678. FDFC 3E FF       LD A,#FF
  679. FDFE 37          SCF
  680. FDFF CD 56 05    CALL #0556
  681.  
  682.  This portion of code loads in a block of code, with the start
  683. #8000 and the length #1B00.
  684.  
  685. FE02 3E 00       LD A,#00
  686. FE04 D3 FE       OUT (#FE),A
  687.  
  688.  This part of the code includes an OUT instruction, but OUT in
  689. machine code is exactly indentical to that in BASIC. So, this
  690. routine is basically the equivalent of OUT 254,0 in BASIC. If you
  691. don't know what that does, it sets the border to black.
  692.  
  693. FE06 11 00 40    LD DE,#4000
  694. FE09 21 00 80    LD HL,#8000
  695. FE0C 01 00 1B    LD BC,#1B00
  696. FE0F ED B0       LDIR
  697.  
  698.  This is another LDIR, and it moves the code from #8000 to #4000
  699. for #1B00 bytes. In other words, it copies the screen picture
  700. into the screen memory so you can see it.
  701.  
  702. FE11 11 60 9D    LD DE,#9D60
  703. FE14 DD 21 B4 5F LD IX,#5FB4
  704. FE18 37          SCF
  705. FE19 3E FF       LD A,#FF
  706. FE1B CD 56 05    CALL #0556
  707.  
  708.  This part of code loads another block, with start 5FB4 and
  709. length 9D60.
  710.  
  711. FE1E C3 C7 61    JP 61C7
  712.  
  713.  This part of the routine jumps to the game itself once it is
  714. loaded.
  715.  
  716.  To hack the game, replace the C3 at FE1E with C9. This will put
  717. a RET at the end of all the code, so the loader will return to
  718. BASIC when all loading has finished.
  719.  
  720.  When the OK message comes up, you can hack the game as you've
  721. done with unprotected games. If you load STK into address #6000
  722. (24576 decimal), and hack the game using a forwards trace, you'll
  723. eventually find that changing #EF09 to 0 gives you infinite lives
  724. for player one. Then to start the game, type RANDOMIZE USR 25031
  725. (61C7 in decimal), and bingo!
  726.  
  727.  To write a hack, we need to rewrite the BASIC loader, but make
  728. the modifications so we can put POKEs in:
  729.  
  730. 10 CLEAR 24999
  731. 20 LOAD "" CODE 65000
  732.  
  733. This comes directly from the BASIC loader and loads the small
  734. headerless loader code.
  735.  
  736. 30 POKE 65054,201
  737.  
  738. This means that control will return to BASIC when all the
  739. headerless code has been loaded
  740.  
  741. 40 RANDOMIZE USR 65000
  742.  
  743. This starts off the headerless loader.
  744.  
  745. 50 POKE 61193,0
  746.  
  747. This is the infinite lives POKE
  748.  
  749.  
  750. 60 RANDOMIZE USR 25031
  751.  
  752. This starts the game itself. Easy when you know how!
  753.  
  754.  Now we know how a simple headerless loader works, let's crack a
  755. turboloader. There are loads of YS covertape games which have a
  756. suitable loader, but I'm going to choose Pixy the Microdot 2,
  757. although you'll find that any YS game which uses blue, black and
  758. magenta stripes when loading is almost identical.
  759.  
  760.  First of all, load up STK at address 58550 (you'll find out why
  761. later on), to find out what the BASIC loader has to say, using
  762. the same method as with Ethnipod. It starts running at line 0.
  763.  
  764. 1 BORDER 0:PAPER 0:CLEAR 64999:LOAD "" CODE
  765. 2 RANDOMIZE USR 65146
  766. 20 CLEAR 64999:LOAD "mc" CODE:LOAD "pixldsy"
  767. CODE:SAVE "t:":SAVE "PIXY" LINE 1:SAVE "x"
  768. CODE 65146,200:LOAD "screen" SCREEN$:RANDOMIZE
  769. USR 65000
  770.  
  771.  The BASIC starts at line 1. The commands should be obvious to
  772. you. Type CLEAR 64999:LOAD "" CODE, start the tape, and load in
  773. the first block of code. Stop the tape when the OK message comes
  774. up.
  775.  
  776.  Now load your disassembler and examine the code at 65146, which is
  777. FE7A hex.
  778.  
  779. FE7A F3           DI
  780.  
  781.  DI is short for "disable interrupts". What are interrupts, I
  782. hear you ask? Well, imagine you're watching TV when suddenly,
  783. someone says "We interrupt this program to give you an important
  784. newsflash!" Then, after the newsflash, the program you were
  785. watching resumes. Well, computer interrupts work in exactly the
  786. same way. In fact, every fiftieth of a second, a program is
  787. "interrupted" by the computer, which then checks to see if you're
  788. pressing any keys, and resumes the original program. The command
  789. DI simply stops this happening, and your program continues
  790. without any interruption! This makes the program run faster.
  791. However, you CANNOT get back to BASIC by a RET command, because
  792. the computer won't be checking the keyboard, and so it has
  793. effectively locked up. To get round this, you must execute the
  794. command EI (enable interrupts) first, so control can be resumed.
  795. Don't worry about doing this now, though.
  796.  
  797. FE7B 31 60 61    LD SP,6160
  798.  
  799.  This is a new instruction. SP (short for "stack pointer") is a
  800. 16-bit register, like BC, DE and HL. However, it's far more
  801. important as far as BASIC is concerned. In machine code, there
  802. are two ways of storing numbers. The first, using memory
  803. locations, we've already come across. However, there is another
  804. method by storing numbers on what is called a stack. Think of a
  805. stack as a big spike on which you can push pieces of paper with
  806. information on. Then, later on, you can take them off the stack
  807. and use them. If you think about it, if you put the numbers 1, 2
  808. and 3 on the stack, in that order, you'll have to take 3 off
  809. first, then 2, then 1 (think about it). And it's the same in
  810. machine code. There are instructions which enable values of
  811. registers to be put on the stack, and which enable the value on
  812. the top of the stack to be taken off and put in a register.
  813.  The stack, like everything else, has to go somewhere in memory.
  814. The SP (stack pointer) register gives the address of the top of
  815. the stack. So LD SP,6160 will mean that the stack is to start at
  816. address 6160.
  817.  This is bad news if you want to return to BASIC, because the
  818. Spectrum's ROM program puts lots of information on the stack, so
  819. if you change the stack pointer, it's going to receive garbage
  820. when it takes all the values off what it thinks is the stack. And
  821. that, of course, will mean a crash. So the general rule is LEAVE
  822. THE STACK POINTER ALONE!
  823.  You can change the value of the stack pointer using CLEAR from
  824. BASIC. If a machine code instruction has LD SP,XXXX, you can type
  825. CLEAR (XXXX)-1. So here, we should CLEAR (#6160)-1 = #615F. Bear
  826. in mind that the value will have to be in decimal, which is
  827. 24927. So exit from STK, CLEAR 24927, and go back into it again.
  828. This will mean that later on we can do the EI / RET as described
  829. above. Then you have to remove the LD SP instruction, which is
  830. most easily done by changing FE7B to 21, so it reads LD HL,6160.
  831. This is harmless in this case.
  832.  Carrying on through the code....
  833.  
  834. FE7E DD 21 00 40 LD IX,4000
  835. FE82 11 00 1B    LD DE,1B00
  836. FE85 CD 97 FE    CALL FE97
  837.  
  838.  As you can probably see, this loads a headerless block, the
  839. loading screen, in fact. However, you'll notice, as I said
  840. eariler, that some of the other commands (LD A,#FF and SCF) are
  841. missing, and the CALL goes to a different address. This is
  842. because it's a turboloader.
  843.  
  844. FE88 DD 21 60 61 LD IX,6160
  845. FE8C 11 4B 83    LD DE,834B
  846. FE8F CD 97 FE    CALL FE97
  847.  
  848.  This loads another block, start 6160 and length 834B. This
  849. means, that all the memory from 6160 to E4AB will be overwritten.
  850. Fortunately, you loaded STK into address 58550, which is E4B6
  851. hex, so it won't be overwritten. Clever, eh? Meanwhile....
  852.  
  853. FE92 30 F4       JR NC,FE88
  854.  
  855.  Something I haven't told you yet is that after a headerless
  856. load, a JR NC will result in that JR if there is a tape loading
  857. error. So, if there was a tape loading error in loading this
  858. game, the JR NC,FE88 would be executed (so that computer would
  859. try and reload the block).
  860.  
  861. FE94 C3 60 61    JP 6160
  862.  
  863. This starts the main program running.
  864.  
  865.  To crack the loader, therefore, POKE FE94 with FB (for EI) and
  866. FE95 with C9 (for RET), along with the modifications I've already
  867. told you about. Then RANDOMIZE USR 65146, and restart the tape
  868. (it is possible that you didn't stop the tape quickly enough the
  869. previous time, so you'll miss the turboload header, in which case
  870. wind back just before  it). When the game has finished loading,
  871. an OK message will appear.
  872.  
  873.  And that's it! Well, actually it's not, because the game is
  874. actually compressed, and needs to be unpacked first. Don't worry,
  875. because it's easy to hack. Go into STK again, and look at address
  876. 6160. You're looking for a JP instruction to the game, which is
  877. what is executed when the game is unpacked. You'll find it at
  878. 61A3. So POKE 61A3,FB and 61A4,C9 (for an EI / RET), and
  879. RANDOMIZE USR 24928. Wait a few seconds until BASIC returns. And
  880. there we are - you've cracked the loader!
  881.  
  882.  You might be wondering how you can tell that the game is
  883. compressed. Well, there are two things. Firstly, the JP from the
  884. loader (6160) is to a very low address in the usuable RAM (which
  885. only starts at 5B00). But more noticeable, you won't be able to
  886. do a forwards trace or a backwards trace until you run the
  887. decompressor. In fact, in general, if you think you should be
  888. able to forwards trace or backwards trace a game for infinite
  889. lives, and haven't overloaded any important code with a
  890. disassembler, but nothing happens, its worth looking at the start
  891. of the code executed and seeing if there's a JP a bit later on to
  892. a completely different address.
  893.  
  894.  So now, perhaps, we should write a complete hack for the game.
  895.  
  896. 10 CLEAR 24927:LOAD "" CODE
  897.  
  898. This is from the BASIC loader and loads in the first block of
  899. code. We've changed the CLEAR though, so the stack is in the
  900. right place.
  901.  
  902. 20 POKE 65147,33
  903.  
  904. This changes the LD SP,6160 into LD HL,6160 so the SP isn't
  905. tampered with.
  906.  
  907. 30 POKE 65172,251:POKE 65173,201
  908.  
  909. This changes the JP 6160 to an EI / RET so control will return to
  910. our hack once the game has loaded.
  911.  
  912.  
  913. 40 RANDOMIZE USR 65146
  914.  
  915. This starts the game loading
  916.  
  917. 50 POKE 24995,251:POKE 24996,201
  918.  
  919. This changes the JP 86CE to an EI / RET so control will return to
  920. our hack once the game has decompressed
  921.  
  922. 60 RANDOMIZE USR 24928
  923.  
  924. This starts the game decompressor.
  925.  
  926. 70 POKE 28402,0
  927.  
  928. This is the infinite lives POKE, which you'll find out when you
  929. do a forwards trace on the uncompressed game.
  930.  
  931. 80 RANDOMIZE USR 34510
  932.  
  933. This is the start of the game.
  934.  
  935.  Now that you've done that, why not crack another game which uses
  936. the same loader? They're nearly all the same, except some of the
  937. JP addresses will be different. And then when you've done that,
  938. why not have a look at some other headerless loaders - most games
  939. by Codemasters use them.
  940.  
  941.  You will find, however, that you will sometimes have to
  942. overwrite some of the memory with your disassembler. There's no
  943. easy way to tell where it should be, I'm afraid, so you'll have
  944. to take pot luck. If your forwards trace and backwards trace are
  945. both unsuccessful, try loading the disassembler elsewhere in
  946. memory, or look to see if the game is compressed.
  947.  
  948. PART 4 - DECRYPTERS
  949.  
  950.  By this point, you should be familiar with headerless loaders,
  951. which take up the bulk of most protection systems these days.
  952. However, there is one other important aspect of protection that
  953. you need to know about if you are to crack the more complex
  954. protection systems. It's encryption.
  955.  
  956.  Encryption works like a secret code. You start off with somthing
  957. unintelligable, then you use the "secret rules" to change it into
  958. something that makes sense. So, IBDLFST doesn't make much sense,
  959. but if you take the previous letter in the alphabet each time,
  960. you get HACKERS, which makes perfect sense. Encryption works in
  961. roughly the same way. We've already seen that a loading system
  962. occupies a small area of memory. An encrypted loading system will
  963. appear as a block of code which makes absolutely no sense
  964. whatsoever. There will also be a short program which changes all
  965. this nonsense into workable code so the loading system can be
  966. run. Some really tough loading systems, have more than one
  967. decrypter, such as the Alkatrazz loading system which has 250 of
  968. the damn things; in practice I've got through about 25 before
  969. going mad and hacking something else (don't worry, there's
  970. another way of hacking them which I'll tell you about later.)
  971.  
  972.  To make it easier for you to understand decryption, its best to
  973. have a look at a real loading system. As an example, I've chosen
  974. Impossaball, which was on the YS#75 covertape. Load up STK at
  975. address 50000 (it's a safe address), and see what the BASIC has
  976. to say for itself by BLOADing it......
  977.  
  978. 10 CLEAR 64530: LOAD "" CODE:RANDOMIZE USR 64531
  979. 20 LOAD "" CODE 16384
  980. 21 FOR i=1 TO 40 STEP - RANDOMIZE USR 50000
  981.  
  982.  Fair enough - so enter CLEAR 64530:LOAD "" CODE and start the
  983. tape. The first code block loads in, and then - it crashes!
  984. What's going on? Don't worry, you have just fallen victim to the
  985. first type of encryption - BASIC encryption.
  986.  
  987.  In BASIC, any numerical constant (technotwaddle for "number")
  988. between 0 and 65,535 is stored in the memory as follows. First,
  989. there is the number in it's ASCII form, which takes between 1 and
  990. 5 bytes. So, the number 1234 will appear as #30,#31#,#32,#33
  991. here. Then, come the numbers #0D,#00 and 00 (this is always the
  992. case). Then, there is the number stored in it's two byte form (as
  993. in machine code). What happens it that the computer prints the
  994. ASCII form (which is what you get when you LIST a program), but
  995. uses the two-byte form in calculations and expressions. The
  996. upshot of all this is that what you see isn't always what you
  997. get! As an example, type in this:
  998.  
  999. 1 PRINT 1
  1000.  
  1001.  Now type POKE 23760,50 (which changes the ASCII value of the
  1002. number 1 from "1" to "2"). Now if you LIST the program, you will
  1003. see 1 PRINT 2, but if you RUN the program, the computer will
  1004. print the number 1 instead!
  1005.  Needless to say, protection systems use the same idea.
  1006. Sometimes, the numbers listed are obviously fake (if you list a
  1007. program and you get something like 0 CLEAR 0:RANDOMIZE USR 0 it's
  1008. obviously got encrypted BASIC), but some programs, like the
  1009. Impossaball are not obvious at all until you try executing what
  1010. you see.
  1011.  
  1012.  There was a program called *List printed ages ago in YS, but if
  1013. you haven't got that, I've reprinted it here. So type it in, SAVE
  1014. it to tape, RUN it and reload the Impossaball BASIC loader.
  1015.  
  1016. loading LINE 10 LEN 81
  1017.  
  1018. 10 CLEAR 25599: LOAD "" CODE: RANDOMIZE USR 64512
  1019. 20 LOAD "" CODE 16384
  1020. 21 FOR i=1 TO 40 STEP ????....
  1021.  
  1022.  Now that's what you really get! Type CLEAR 25599:LOAD "" CODE
  1023. and load in the first block of code. When that's done, load up
  1024. your disassembler, and disassemble address 64512 (FC00 hex) to
  1025. have a look at the decrypter.
  1026.  
  1027. FC00 01 99 02   LD BC,#0299
  1028. FC03 21 13 FC   LD HL,#FC13
  1029. FC06 11 14 FC   LD DE,#FC14
  1030.  
  1031.  This part of the program sets up all the initial values for the
  1032. decrypters in some of the registers.
  1033.  
  1034. FC09 1A         LD A,(DE)
  1035.  
  1036.  We've come across brackets before, but briefly what happens here
  1037. is that the contents of the address with the value of the DE
  1038. register (which starts of as #FC14) are put into the A register.
  1039. So now the A register could contain any byte.
  1040.  
  1041. FC0A AE         XOR (HL)
  1042.  
  1043.  We haven't seen XOR before, so I'll explain what it does. It is
  1044. in technical terms a Boolean Operation. You may have seen XOR
  1045. gates if you studied (or are studying!) Physics, Electronics or
  1046. Computer Science at school. An XOR gate has two inputs, which can
  1047. each either be 0 or 1, and one output, which can be either 0 or 1
  1048. as well. If the two inputs are the same (0 and 0, or 1 and 1),
  1049. the output is 0, otherwise it is 1. In machine code, you XOR the
  1050. A register with a number or contents of a register, and what
  1051. happens is that each bit in the A register is XORed with the same
  1052. bit in the number or register contents, and the result is stored
  1053. in the A register. If you're confused, look at the example below.
  1054.  
  1055. Contents of the A register   00100101
  1056. Number to be XORed with      01010011
  1057. Result                       01110110
  1058.  
  1059. (Notice that all the numbers are in binary - see your Spectrum
  1060. manual for more information about this).
  1061.  
  1062.  If you still don't understand, just remember that an XOR will
  1063. change the contents of the A register. That's all you need to
  1064. remember for now.
  1065.  
  1066.  Continuing the disassembly...
  1067.  
  1068. FC0B 77       LD (HL),A
  1069.  
  1070.  This puts the value of A (which has just been changed) into the
  1071. bytes at the address with the value of the HL register (which
  1072. starts off as #FC13).
  1073.  So, the routine has basically taken a byte out of a memory
  1074. location, changed it a bit, and put the altered value back again.
  1075. This is decryption in its most obvious form - the changed values
  1076. make up a working machine code program.
  1077.  
  1078. FC0C 23       INC HL
  1079. FC0D 13       INC DE
  1080. FC0E 0B       DEC BC
  1081.  
  1082.  I don't think I've mentioned INC before, but it's basically the
  1083. opposite of DEC in that it increases the value in whatever
  1084. register. So the values in the HL and DE registers are
  1085. incremented, and the value in the BC register is decremented.
  1086.  
  1087. FC0F 78       LD A,B
  1088. FC10 B1       OR C
  1089. FC11 20 F6    JR NZ,#FC09
  1090.  
  1091.  This is a standard piece of code, and it essentially means "If
  1092. BC isn't 0, then jump to #FC09". In other words, another byte
  1093. will be decrypted until the value of BC is 0 (which happens when
  1094. everything has been decrypted), and the decrypter ends.
  1095.  
  1096.  Continuing the disassembly...
  1097.  
  1098. FC13 5C       LD E,H
  1099. FC14 9F       SBC A,A
  1100. FC15 A5       AND L
  1101. FC16 5B       LD E,E
  1102. FC17 13       INC DE
  1103. FC18 5B       LD E,E
  1104. ....
  1105.  
  1106.  Hang on - this code doesn't make sense! It has no relation to
  1107. the code above, and the instruction LD E,E is pointless anyway.
  1108. Well, you'll remember that the initial value of decryption is
  1109. #FC13, which means that all the code from there onwards has to be
  1110. decrypted. So we'll have to crack the decrypter to go any
  1111. further.
  1112.  Sometimes, it is possible to put an EI/RET instruction directly
  1113. after the decrypter, but this is not possible here, as you will
  1114. see. So instead, we'll have to move the decrypter somewhere else
  1115. in memory, and put the EI/RET on the end (in actual fact we don't
  1116. need the EI because there is no DI command in the decrypter).
  1117. This is easily done by using the LDIR command. Type in the
  1118. following program:
  1119.  
  1120. 1 FOR N=23296 TO 23310:INPUT A:POKE N,A:NEXT N
  1121.  
  1122.  Now RUN it and enter the following numbers:
  1123.  
  1124. 33,0,252,17,128,91,1,1,18,0,237,176,54,201,201
  1125.  
  1126.  The program you have just typed in is this:
  1127.  
  1128. LD HL,FC00
  1129. LD DE,5B80
  1130. LD BC,0012
  1131. LDIR
  1132. LD (HL),C9
  1133. RET
  1134.  
  1135.  Now RANDOMIZE USR 23296 and the decrypter will be copied to 5B80
  1136. and a RET will be stuck on the end. Just RANDOMIZE USR 23424
  1137. (5B80 in decimal) to run the decrypter. When the OK message comes
  1138. up, restart the disassembler and look at FC13 again:
  1139.  
  1140. FC13 C3 3A FE   JP #FE3A
  1141.  
  1142.  This jumps to #FE3A, to start the loading.
  1143.  
  1144. FE3A F3         DI
  1145. FE3B 21 00 58   LD HL,#5800
  1146. FE3E 11 01 58   LD DE,#5801
  1147. FE41 01 FF 02   LD BC,#02FF
  1148. FE44 36 00      LDIR
  1149.  
  1150. As you already know, this makes the screen black.
  1151.  
  1152. FE48 CD 81 FE   CALL #FE81
  1153. FE4B CD 00 80   CALL #8000
  1154.  
  1155.  If you look at the code at #FE81, you'll see it's a headerless
  1156. loader. The routine at #8000 prints the loading screen.
  1157.  
  1158. FE4E CD 81 FE   CALL #FE81
  1159. FE51 CD 00 64   CALL #6400
  1160.  
  1161.  This loads another block (the main game), and prints another
  1162. screen (the border for the game).
  1163.  
  1164. FE54 F3         DI
  1165. FE55 31 FF FF   LD SP,#FFFF
  1166.  
  1167.  This disables interrupts and changes the stack pointer, so we'll
  1168. have to change that in the final hack.
  1169.  
  1170. FE58 21 00 6D   LD HL,#6000
  1171. FE5B 11 00 5B   LD DE,#5B00
  1172. FE5E 01 00 8F   LD BC,#8F00
  1173. FE61 ED BO      LDIR
  1174.  
  1175.  This is another LDIR command, but if you know how the Spectrum's
  1176. memory is organised, you will see that the BASIC system variables
  1177. are overwritten, which means we can't return to BASIC when the
  1178. game has loaded. Fortunately, there's a short routine to get
  1179. round this, which I'll explain in a mo.
  1180.  
  1181. FE63 21 71 FE   LD HL,#FE71
  1182. FE66 11 00 F0   LD DE,#F000
  1183. FE69 01 10 00   LD BC,#0010
  1184. FE6C ED B0      LDIR
  1185. FE6E C3 00 F0   JP F000
  1186.  
  1187.  This moves the code from FE71 to F000, and jumps to F000.
  1188. Obviously, then, the code at FE71 is important.
  1189.  
  1190. FE71 21 00 FC   LD HL,#FC00
  1191. FE74 11 01 FC   LD DE,#FC01
  1192. FE77 01 FF 01   LD BC,#01FF
  1193. FE7A 36 00      LD (HL),0
  1194. FE7C ED B0      LDIR
  1195. FE7E C3 00 80   JP #8000
  1196.  
  1197.  This routine wipes out all the memory from #FC00 to #FC01, but
  1198. in actual fact you don't need to do this. Then it jumps to #8000,
  1199. which is the start of the game. So, we can put a machine code
  1200. routine to put a POKE in, and then jump to #8000.
  1201.  However, we've got to find the POKE first, and there's the
  1202. problem that we can't use BASIC because it is overwritten.
  1203. Luckily, there is a short routine you can use which will cause a
  1204. NEW to a certain address. Put it into the above program by typing
  1205. in the following:
  1206.  
  1207. 1 FOR N=65137 TO 65144:INPUT A:POKE N,A:NEXT N
  1208.  
  1209. Then RUN it, and enter these numbers in turn:
  1210.  
  1211. 243,175,17,0,95,195,203,17
  1212.  
  1213.  The program you've just typed in is the following:
  1214.  
  1215. DI
  1216. XOR A
  1217. LD DE,#5F00
  1218. JP #11CB
  1219.  
  1220.  DI disables interrupts, XOR A loads A with 0 (think about what
  1221. would happen if you XORed the value of the A register with
  1222. itself, LD DE,#5F00 means we want to NEW up to #5F00 (this value
  1223. can be changed from about #5D00 to #FFFF), and JP #11CB starts
  1224. the NEW.
  1225.  
  1226.  Now RANDOMIZE USR 65082 (#FE3A in decimal), and restart the game
  1227. tape. When the computer resets, you can load STK into address
  1228. 24320 to find POKEs.
  1229.  
  1230.  Phew! And that's about all of that protection system cleared up.
  1231. If you can get your way through that lot, I think you're probably
  1232. ready to have a go at a "commercial" protection system. First,
  1233. though, we'll write a complete hack for the game.
  1234.  
  1235. 10 CLEAR 25599:LOAD "" CODE
  1236.  
  1237.  This is from the BASIC loader, and it loads in the first machine
  1238. code block
  1239.  
  1240. 20 FOR N=23296 TO 23310:READ A:POKE N,A:NEXT N
  1241.  
  1242.  This line POKEs in the machine code program to move the
  1243. decrypter.
  1244.  
  1245. 30 DATA 33,0,252,17,128,91,1,19,0,237,176,54,201,201
  1246.  
  1247. And here's the actual machine code itself
  1248.  
  1249. 40 RANDOMIZE USR 23296
  1250.  
  1251. This line calls the decrypter and returns to BASIC
  1252.  
  1253. 40 FOR N=65137 TO 65143: READ A:POKE N,A:NEXT N
  1254.  
  1255. This line POKEs in our hacking program
  1256.  
  1257. 50 DATA 175,50,??,??,195,0,128
  1258.  
  1259.  And here's the hacking program, which loads ???? with 0 (which is
  1260. the infinite lives POKE), and jumps to #8000.
  1261.  
  1262. 60 RANDOMIZE USR 65082
  1263.  
  1264.  This starts the whole loading system off, with the POKE firmly in
  1265. place.
  1266.  
  1267.  And that's about it. A bit of a long piece of work, but it was
  1268. worth it!
  1269.  
  1270.  
  1271. PART 5 - Advanced Hacking Methods
  1272.  
  1273.  Remember in Part 2, when I said there were other ways of
  1274. hacking, apart from forwards and backwards tracing? Well, you can
  1275. find them here. But you need a Multiface to be able to use them.
  1276. The two we're interested with here are what I call a stack trace
  1277. and an interrupt trace.
  1278.  
  1279. STACK TRACE:
  1280.  
  1281.  We've already come across the stack as a means of storing
  1282. numbers. What you haven't come across yet is how the stack is
  1283. used. Well, in a CALL to a subroutine, what actually happens is
  1284. that the return address from the subroutine (which is the address
  1285. after the CALL instruction) is stored on the stack, and with a
  1286. RET, the top value of thhe stack is taken off and jumped to.
  1287.  With a Multiface, the value on the top of the stack is the
  1288. return address to the program. and subsequent values refer to
  1289. return addresses in subroutines.
  1290.  To do a stack trace, load and play the game, and wait until the
  1291. "death effect" occurs - this may be a beep, a flashing border or
  1292. something else recognisable. Now quickly press the Multiface
  1293. button during this effect - if you're too slow, you won't get
  1294. the values you're looking for (so return to the game and die
  1295. again). Now, look at the value of the stack pointer (your
  1296. Multiface manual will tell you how to do this), and write down
  1297. all the values on top of the stack for the first ten bytes. All
  1298. numbers are stored in the normal reversed two-byte form, so if
  1299. the bytes on the top of the stack were #00,#80,#80,#70,#90,#60,
  1300. the values would be #8000,#7080 and #6090. Have a look at all of
  1301. these addresses - you should find that some of them are addresses
  1302. right after CALL instructions.
  1303.  Now for the hacking bit - go to one of these address and write
  1304. down the two bytes there. Then change them to the magic codes #18
  1305. and #FE (this is the machine code version of JR -2, which is an
  1306. endless loop, a bit like 1 GOTO 1 in BASIC). Restart the game,
  1307. and hopefully, you'll find that the game pauses as soon as you do
  1308. something which would normally result in you losing a life! (If
  1309. not, replace the #18FE with the original two bytes, look at
  1310. another address on the "hit list" and repeat the whole
  1311. procedure).
  1312.  Once you've found a target address, try putting a RET (#C9) at
  1313. the start of the subroutine. If this just cancels the death
  1314. effect, but you still "die", activate the Genie Disassembler if
  1315. you have it (or use the NEW routine in Part 4 at any address,
  1316. then load in STK or Devpac somewhere far away from the area of
  1317. memory you're looking at), and search for CALLs to this routine.
  1318. Then go back from this CALL until you find a RET or a JP, and
  1319. search for the address of the instruction after this (if nothing
  1320. comes up, search for one more than this, then two more etc.). You
  1321. will hopefully either see one of these:
  1322.  
  1323. JP Z
  1324. JP NZ
  1325. JP C
  1326. JP NC
  1327.  
  1328. (The JP may be a JR or a CALL instead)
  1329.  
  1330.  Simply overwrite this instruction with NOPs to get immunity or
  1331. something similar.
  1332.  On the other hand, when searching from the CALL address, you may
  1333. find a JP Z or JP NZ, etc. Change this to an unconditional JP to
  1334. get immunity.
  1335.  
  1336. INTERRUPT TRACE:
  1337.  
  1338.  This involves looking at the interrupt routine in the game.
  1339. Since the whole routine must be executed in 1/50th of a second,
  1340. the routines are usually quite short, especially if there is a
  1341. LDIR or something similar. Most of the time you'll find infinite
  1342. time in this routine (because interrupts work in real time, so
  1343. its an ideal place to put a time routine), and you need a
  1344. Multiface to find it.
  1345.  Load the game and start playing as normal. Then activate the
  1346. Multiface, and have a look at the I register. If the value is
  1347. #3F, there are no special interrupts, so forget about an
  1348. interrupt trace altogether (but you can use a stack trace which
  1349. will make the clock loop round to 99 or whatever when it reaches
  1350. 0). If it is between #80 and #FF (and if it's not in that range
  1351. and not #3F you've probably crashed the computer!), go to the
  1352. address #100 time that of the value in the I register (so if the
  1353. value of I is #F0, look at #F000). You will see an area of memory
  1354. filled with the same number. Go to this address (if this area of
  1355. memory is filled with #FE, go to #FEFE etc.) There will either be
  1356. a jump to the interrupts routine, or the interrupts routine
  1357. itself. Have a look at the routine, and somewhere you will see
  1358. the commands to decrease the timer - just remove the DEC
  1359. instruction to get infinite time.
  1360.  
  1361. PART 6 - Commercial Protection Systems
  1362.  
  1363.  If you can understand everything we've done so far, you can now
  1364. probably crack just about any budget game or YS covergame that's
  1365. thrown at you. And indeed, you can probably get featured in
  1366. "Practical POKEs" month in month out (like a load of anonymous
  1367. hackers, I might add!) by using the knowledge you've got.
  1368. However, if you want to become a hacking legend, you should have
  1369. a go at some of the numerous commercial protection systems, which
  1370. have been written by freelancers for software houses.
  1371.  I think we're getting seriously into Multiface territory now,
  1372. but I'll try and do as much as possible with only STK and 007
  1373. Disassembler.
  1374.  I think I should also say that cracking commercial protection
  1375. systems is NOT easy. The code is deliberately badly structured
  1376. and obscurely coded to put you off, so you'll have to perservere.
  1377. You really do need something like a Multiface or Devpac to crack
  1378. some of these systems, because they can overwrite the system
  1379. variabes in BASIC, and you sometimes need to know the values of
  1380. certain registers, which is impossible to determine using BASIC.
  1381. You'll also need some games other than YS stuff to hack, but
  1382. fortunately, protection systems such as Speedlock or Alkatrazz
  1383. are so common, you're bound to have a game with one of them on.
  1384. I'll be doing examples specific to one game, but you'll find that
  1385. onther game with the same protection is pretty much the same,
  1386. except you're likely to find that some of the addresses will be
  1387. different.
  1388.  Before we start, I'd just like to point out that I'll be
  1389. referring to the term "breakpoint" a lot. This is simply a small
  1390. bit of code which will stop the program dead in its tracks. Using
  1391. DEVPAC, you just press the W key. On a Multiface, you do the same
  1392. as a stack trace, by writing down the two bytes at the place you
  1393. want to put a breakpoint, then replacing them with #18 and #FE.
  1394. If you are using 007 disassembler and/or STK, you'll need to put
  1395. a jump to the start of the program (#C3 #00 #40 for 007
  1396. disassembler; STK varies depending on where you put it).
  1397.  
  1398.  So let's start with something relatively simple....
  1399.  
  1400. BLEEPLOAD
  1401.  
  1402.  "Bleepload" first appeared on Firebird games around March 1987,
  1403. and was used by them on every release by them from then on until
  1404. their demise in 1989. It emulates a BBC loading system in that
  1405. each file loads in a series of blocks, which are numbered in
  1406. hexadecimal. The hardness is not because it uses non standard
  1407. cde, it's just that it jumps around so much in memory you need to
  1408. put in an awful lot of software patches.
  1409.  I'll be hacking Bubble Bobble as an example.
  1410.  
  1411. First of all, load in *Hack, and load in the BASIC loader.
  1412.  
  1413. Bubble LINE 10 LEN 179
  1414.  
  1415. 10 REM
  1416. 20 CLEAR 50000
  1417. 30 BORDER 0:PAPER 0:INK 0:CLS
  1418. 40 PRINT AT 1,7;PAPER 1;INK 7;"BUBBLE BOBBLE"
  1419. 50 LOAD "Bobble" CODE 52480
  1420. 60 RANDOMIZE USR 52480
  1421.  
  1422.  There is absolutely nothing difficult about this BASIC loader,
  1423. so just type CLEAR 50000:LOAD "" CODE and start the tape to load
  1424. the first block of code. Stop the tape when it's loaded, and load
  1425. in your disassembler into address 32768 (it's a safe one), and
  1426. have a look at the code at CD00.
  1427.  
  1428. CD00 3A 5C 5B    LD A,(#5B5C)
  1429. CD03 32 00 60    LD (#6000),A
  1430.  
  1431.  This takes the byte at #5B5C and puts it in #6000. #5B5C is the
  1432. system variable for the 128K page number, in case you're
  1433. interested.
  1434.  
  1435. CD06 3E 02       LD A,#02
  1436. CD08 CD 01 16    CALL #1601
  1437.  
  1438.  This is a standard ROM routine, and all it does it to tell the
  1439. computer we want to print something on the screen.
  1440.  
  1441. CD0B AF          XOR A
  1442. CD0C 32 6B 5C    LD (#5C6B),A
  1443.  
  1444.  As you may be aware, poking #5C6B (23659 decimal) with 0 will
  1445. cause the computer to crash if you press BREAK or return to
  1446. BASIC. So POKE CD0E,0 which changes it to LD (#006B),A; this is
  1447. harmless.
  1448.  
  1449. CD0F CD CE CE    CALL #CECE
  1450.  
  1451.  The routine at #CECE prints the message "Searching" on screen.
  1452.  
  1453. CD12 10 09       DJNZ #CD1D
  1454.  
  1455.  We haven't come across the command DJNZ before. It basically
  1456. means "decrease the value in the B register, and jump if B is not
  1457. zero."
  1458.  
  1459. CD14 11 08 FF    LD DE,#FF08
  1460. CD17 16 00       LD D,0
  1461. CD19 CD 1A CE    CALL #CEA1
  1462.  
  1463. This routine prints the number 00 on screen.
  1464.  
  1465. CD1C 3E 08       LD A,#08
  1466. CD1E 32 15 FF    LD (#FF15),A
  1467. CD21 CD 74 CD    CALL #CD74
  1468.  
  1469.  This routine loads in a block of code from tape (in actual fact
  1470. the start address is #FE00 and its length is #100 bytes).
  1471.  
  1472. CD24 3E 00 FA    LD A,(#FE00)
  1473. CD27 FE 64       CP #64
  1474. CD29 20 F6       JR NZ,#CD21
  1475.  
  1476.  This routine loads A with the value at #FE00. The CP instruction
  1477. compares the value in the A register with something, in this case
  1478. the number #64. If there is no match, the routine jumps back to
  1479. #CD21, otherwise it continues. This routine actually checks to
  1480. see if the block is found.
  1481.  
  1482. CD2B 3A 01 FF    LD A,(#FF01)
  1483. CD2E BA          CP D
  1484. CD2F 28 05       JR Z,#CD36
  1485.  
  1486.  This routine checks to see if the block has been loaded
  1487. successfully. If so, it jumps to #CD36, otherwise it continues.
  1488.  
  1489. CD31 CD 84 CE    CALL #CE84
  1490. CD34 18 EB       JP #CD21
  1491.  
  1492.  This routine prints up the "loading error" message, and attemps
  1493. to load the block again.
  1494.  
  1495. CD36 CD 30 CE    CALL #CE30
  1496.  
  1497.  The routine at #CE30 is a decrypter (have a look - do you see
  1498. why?), which decrypts the block loaded in ie: from #FE00 to FEFF.
  1499. You don't need to crack it yourself.
  1500.  
  1501. CD39 BE          CP (HL)
  1502. CD3A 28 05       JR Z,#CD41
  1503.  
  1504.  This routine reloads the block if the value of A equals the
  1505. value at (HL). Don't ask me why.
  1506.  
  1507. CD41 CD 5F CD    CALL #CD5F
  1508.  
  1509.  This routine moves the code at #FE00 to where it should really
  1510. be in memory.
  1511.  
  1512. CD44 CD 5D CE    CALL #CE5D
  1513.  
  1514.  This routine prints the "loading" message on the screen, but
  1515. this should in actual fact be "loaded", because the block has
  1516. just been read in at this point of the code.
  1517.  
  1518. CD47 21 04 FF    LD HL,#FF04
  1519. CD4A 7E          LD A,(HL)
  1520. CD4B 23          INC HL
  1521. CD4C 3D          DEC A
  1522. CD4D 20 FC       JR NZ,#CD4B
  1523. CD4F 23          INC HL
  1524. CD50 23          INC HL
  1525. CD51 23          INC HL
  1526. CD52 23          INC HL
  1527. CD53 7E          LD A,(HL)
  1528. CD54 2B          DEC HL
  1529. CD55 2B          DEC HL
  1530. CD56 2B          DEC HL
  1531. CD57 E6 07       AND #07
  1532. CD59 3C          INC A
  1533. CD5A 32 15 FF    LD (#FF15),A
  1534. CD5D 14          INC D
  1535. CD5E E9          JP (HL)
  1536.  
  1537.  This routine starts off with HL as FF04, then does a lot of
  1538. sums, and comes out with a value in the HL register, which it
  1539. jumps to after its loaded the block. This is what we need to
  1540. hack. So POKE CD5E with C9 and RANDOMIZE USR 52480 - you'll find
  1541. out it loads in one block and then stops. However, this isn't
  1542. much use as you can't find out the value of the HL register. So
  1543. put this routine somewhere, such as #5B00.
  1544.  
  1545. 5B00 CD 00 CD     CALL #CD00
  1546. 5B03 22 10 5B     LD (#5B10),HL
  1547. 5B06 C9           RET
  1548.  
  1549.  This routine simply loads the first block, and puts the value of
  1550. HL in #5B10 so we can find out what it is from BASIC.
  1551.  Now rewind the tape before the first Bleepload block again, and
  1552. RANDOMIZE USR 23296. When that's finished, type PRINT PEEK
  1553. 23312+256*PEEK 23313. You should get the answer 65293, which is
  1554. #FF0D. Disassemble this address.
  1555.  
  1556. FF0D C3 21 CD    JP #CD21
  1557.  
  1558.  This will go back and load the next block from tape. We can
  1559. crack it in the same way as the first be changing our routine at
  1560. 5B00.
  1561.  
  1562. 5B00 CD 00 CD    CALL #CD00
  1563. 5B03 CD 21 CD    CALL #CD21
  1564. 5B06 22 10 5B    LD (#5B10),HL
  1565. 5B09 C9          RET
  1566.  
  1567.  Now wind the tape back to the first Bleepload block again,
  1568. RANDOMIZE USR 23296 and start the tape. When the OK message comes
  1569. up, type PRINT PEEK 23312+256*PEEK 23313, and you should get
  1570. 65286 which is FF06 hex. Disassemble this address.
  1571.  
  1572. FF06 C3 21 CD    JP #CD21
  1573.  
  1574.  This goes back and loads another block. By now, you might have
  1575. guessed that the value of HL will always contain the address of a
  1576. JP #CD21 instruction - except for the last block which will jump
  1577. elsewhere. Now we can write a routine which will load any block
  1578. as long as it jumps to #CD21 at the end. I'm putting the routine
  1579. at #CCEC, because it's right next to the loading system, and
  1580. hence is unlikely to be overloaded (although it could be, in
  1581. which case we'd just put the routine elsewhere). The routine goes
  1582. like this.
  1583.  
  1584. CCEC CD 00 CD    CALL #CD00
  1585.  
  1586. This is just loading the first block
  1587.  
  1588. CCEF CD 21 CD    CALL #CD21
  1589.  
  1590. This loads in a block from tape.
  1591.  
  1592. CCF0 23          INC HL
  1593. CCF1 7E          LD A,(HL)
  1594. CCF2 2B          DEC HL
  1595.  
  1596.  This routine loads the A register with the value of (HL+1). This
  1597. will be #21 if another block is to be loaded.
  1598.  
  1599. CCF3 FE 21       CP #21
  1600. CCF5 20 02       JR NZ,#CCF8
  1601. CCF6 18 F7       JR #CCEF
  1602.  
  1603.  This compares the value in the A register to 21. If there is no
  1604. match, then the routine jumps to the end to preserve the value of
  1605. HL, and to return to BASIC. Otherwise, it goes back to load
  1606. another block.
  1607.  
  1608. CCF8 22 FE CC    LD (#CCFE),HL
  1609. CCFB <breakpoint>
  1610.  
  1611.  This puts the value of HL in address #CCFE, then returns to
  1612. control of the disassembler.
  1613.  
  1614.  Now, run this routine (RANDOMIZE USR 52463), rewind to the first
  1615. Bleepload block, and start loading. The program will now load
  1616. blocks 00-2D, and return to control of the disassembler. The
  1617. value at #CCFE is #FF06, so disassemble this address.
  1618.  
  1619.  
  1620. FF06 C3 00 5B    JP #5B00
  1621.  
  1622.  Now disassemble #5B00, which is the real meat of the loading
  1623. system!
  1624.  
  1625. 5B00 DD E5       PUSH IX
  1626. 5B02 CD 74 CD    CALL #CD74
  1627. 5B05 CD 30 CE    CALL #CE30
  1628. 5B08 28 07       JR Z,#5B12
  1629. 5B0B 06 00       LD B,#00
  1630. 5B0D CD 84 CE    CALL #CE84
  1631. 5B10 18 F0       JR #5B02
  1632.  
  1633.  This routine loads in another block of code, and will jump to
  1634. 5B12 when it has been successfully loaded.
  1635.  
  1636. 5B12 F3          DI
  1637. 5B13 E1          POP HL
  1638. 5B14 2E 00       LD L,#00
  1639. 5B16 ED 5B E7 FE LD DE,(#FEE7)
  1640. 5B1A 1A          LD A,(#DE)
  1641. 5B1B AE          XOR (HL)
  1642. 5B1C 24          INC H
  1643. 5B1D AE          XOR (HL)
  1644. 5B1E 25          DEC H
  1645. 5B1F 12          LD (#DE),A
  1646. 5B20 2C          INC L
  1647. 5B21 IC          INC E
  1648. 5B22 20 F6       JR NZ,#5B1A
  1649.  
  1650.  This routine is a decrypter, which decrypts some of the code we
  1651. just loaded in from tape.
  1652.  
  1653. 5B24 ED 5B E7 FE LD DE,(#FEE7)
  1654. 5B26 21 40 5B    LD HL,#5B40
  1655. 5B2B 1A          LD A,(DE)
  1656. 5B2C AE          XOR (HL)
  1657. 5B2D 77          LD (HL),A
  1658. 5B2E 1C          INC E
  1659. 5B2F 2C          INC L
  1660. 5B30 20 F9       JR NZ,#5B2B
  1661.  
  1662.  This code decrypts some more code loaded in from tape, but it
  1663. puts it at #5B40, which is right in the middle of the code we are
  1664. working on at the moment. So put a breakpoint at #5B32 (the first
  1665. instruction after the decrypter), and jump to #5B00 (because we
  1666. haven't executed any of the code from #5B00 onwards yet!)
  1667.  
  1668. 5B32 21 00 00    LD HL,#0000
  1669. 5B35 22 B0 5C    LD (#5CB0),HL
  1670. 5B38 2E 02       LD A,#02
  1671. 5B3A 32 6B 5C    LD (#5C6B),A
  1672.  
  1673.  This puts the value #0000 into #5CB0, but I'm not sure why,
  1674. because #5CB0 is an unused system variable. It then changes the
  1675. value of #5C6B to #02, which is what it was originally before it
  1676. was changed to protect the loader.
  1677.  
  1678. 5B3D ED 5B E7 FE LD DE,(#FEE7)
  1679. 5B41 2A E9 FE    LD HL,(#FEE9)
  1680. 5B44 1A          LD A,(DE)
  1681. 5B45 AE          XOR (HL)
  1682. 5B46 77          LD (HL),A
  1683. 5B47 23          INC HL
  1684. 5B48 IC          INC E
  1685. 5B49 20 F9       JR NZ,#5B44
  1686. 5B4B 3A EC FE    LA A,(#FEEC)
  1687. 5B4E BC          CP H
  1688. 5B4F 20 F3       JR NZ,#5B44
  1689.  
  1690.  This is another decrypter, which works in exactly the same way
  1691. as the others.
  1692.  
  1693. 5B51 31 FF 60    LD SP,#60FF
  1694. 5B54 21 00 CF    LD HL,#CF00
  1695. 5B57 11 00 40    LD DE,#4000
  1696. 5B5A 01 00 1B    LD BC,#1B00
  1697. 5B5D ED B0       LDIR
  1698. 5B5F 21 00 EA    LD HL,#EA00
  1699. 5B62 11 00 61    LD DE,#6100
  1700. 5B65 01 00 10    LD BC,#1000
  1701. 5B68 ED B0       LDIR
  1702.  
  1703.  This code moves all the decrypted code to where it should be.
  1704. This includes the loading screen (as you can see by the reference
  1705. to #4000.)
  1706.  
  1707. 5B6A 3E 65       LD A,#65
  1708. 5B6C 32 00 5B    LD (#5B00),A
  1709. 5B6F 21 0F 14    LD HL,#140F
  1710. 5B72 22 01 5B    LD (#5B01),HL
  1711. 5B75 21 0F 00    LD HL,#004F
  1712. 5N78 22 03 5B    LD (#5B03),HL
  1713. 5B7B CD 00 FA    CALL #FA00
  1714.  
  1715.  This code loads the next Bleepload block, from 00 to 87, but
  1716. will return to 5B7E when it's finished.
  1717.  
  1718. 5B7E 21 00 40    LD HL,#4000
  1719. 5B81 11 01 40    LD DE,#4001
  1720. 5B84 36 00       LD (HL),0
  1721. 5B86 01 FF 1A    LD BC,#1AFF
  1722. 5B89 ED B0       LDIR
  1723. 5B8B 3E 66       LD A,#66
  1724. 5B8D 32 00 5B    LD (#5B00),A
  1725. 5B90 21 0A 0A    LD HL,#0A0A
  1726. 5B92 22 01 5B    LD (#5B01),HL
  1727. 5B96 21 0D 0A    LD HL,#0A0D
  1728. 5B99 22 03 5B    LD (#5B03),HL
  1729. 5B9C CD 00 FA    CALL #FA00
  1730.  
  1731.  This code blanks out the screen and loads some code into it.
  1732. Some Bleepload games do not have this code, and it is only used
  1733. on games whos game code overwrites the loading system at #FA00.
  1734.  
  1735. 5B9F 21 00 40    LD HL,#4000
  1736. 5BA2 11 00 FA    LD DE,#FA00
  1737. 5BA5 01 00 06    LD BC,#0600
  1738. 5BA8 ED B0       LDIR
  1739.  
  1740.  This moves the code loaded from the screen to #FA00 (where it
  1741. should be).
  1742.  
  1743. 5BAA 3A 00 60    LD A,(#6000)
  1744. 5BAD 32 5C 5B    LD (#5B5C),A
  1745. 5BB0 31 A7 61    LD SP,#61A7
  1746. 5BB3 CD 8E 02    CALL #28E
  1747. 5BB6 28 1D       JR Z,#5BD5
  1748.  
  1749.  This routine restores the value of #5B5C that was stored in
  1750. #6000 right at the very start. It then sets the stack to #61A7,
  1751. and calls the ROM keycheck routine. If no key is pressed (and
  1752. there shouldn't be), the routine jumps to 5BD5. In fact, it must
  1753. jump there, otherwise it would attempt to load a normal
  1754. headerless block, and there are none!
  1755.  
  1756. 5BD5 C3 BC F5    JP #F5BC
  1757.  
  1758.  This is what we've all been waiting for - the JP to the game
  1759. itself. You can simply put POKEs on the end of #5BD5, and follow
  1760. them with a JP #F5BC to load the game. For now, though, it might
  1761. be a good idea to put the NEW routine up to #61A7 there, instead,
  1762. and JP to #5B32 (where we left off). Then load the rest of the
  1763. game, which will reset at the end, enabling you to load in STK,
  1764. Devpac or whatever.
  1765.  
  1766.  Now we've gone all the way through Bleepload, perhaps we should
  1767. write a hack for the complete game. However, I'm going to put
  1768. most of the hack in machine code, rather than have long lines of
  1769. decimal DATA statements. You should be able to convert the
  1770. machine code into DATA statements and get a short program which
  1771. reads them in and POKEs them into memory.
  1772.  The only thing that has to be done from BASIC is the CLEAR
  1773. 50000:LOAD "" CODE 52480 from the BASIC loader. The machine code
  1774. hack will consist of the first routine we wrote, followed by a
  1775. few patches to the main loading system, so that the JP to the
  1776. game is overwritten with our POKEs. I'll be putting it at #CC80,
  1777. because it's a safe place in memory.
  1778.  
  1779.  
  1780. CC80 3E C9        LD A,#C9
  1781. CC82 32 5E CD     LD (#CD5E),A
  1782.  
  1783.  This puts a RET in place of the JP (HL) at #CD5E so we can CALL
  1784. the loading system.
  1785.  
  1786. CC85 CD 00 CD     CALL #CD00
  1787.  
  1788. This loads in the first Bleepload block.
  1789.  
  1790. CC88 CD 21 CD     CALL #CD21
  1791.  
  1792. This loads in another Bleepload block.
  1793.  
  1794. CC8B 23           INC HL
  1795. CC8C 7E           LD A,(HL)
  1796. CC8D 2B           DEC HL
  1797. CC8E FE 21        CP #21
  1798. CC90 20 02        JR NZ,#CC94
  1799. CC92 18 F4        JR #CC88
  1800.  
  1801.  This checks to see if all the Bleepload blocks have been loaded,
  1802. and jumps ahead if they have, otherwise it jumps back to load the
  1803. next block.
  1804.  
  1805. CC94 3E C3       LD A,#C3
  1806. CC96 32 32 5B    LD (#5B32),A
  1807. CC99 21 A1 CC    LD HL,CCA1
  1808. CC9B 22 33 5B    LD (#5B33),HL
  1809. CC9E C3 00 5B    JP #5B00
  1810.  
  1811.  This puts the instruction JP #CCA1 at #5B32 so the loader
  1812. decrypter will return to our hack at #CCA1 when finished.
  1813.  
  1814. CCA1 21 B2 CC    LD HL,#CCB2
  1815. CCA4 11 D5 5B    LD DE,#5BD5
  1816. CCA7 01 08 00    LD BC,#0008
  1817. CCAA ED B0       LDIR
  1818.  
  1819.  This copies the final part of our hacking routine to #5BD5,
  1820. where it will be executed once the whole game has been loaded.
  1821.  
  1822. CCAC 21 00 00    LD HL,#0000
  1823. CCAF C3 35 5B    JP #5B35
  1824.  
  1825.  The LD HL,#0000 instruction is important, because it's the
  1826. instruction we overwrote with out JP back to the hack. Therefore,
  1827. we've got to execute it, otherwise the loading system may crash.
  1828. Then it resumes loading at #5B35 with the POKEs firmly in place.
  1829.  
  1830. CCB2 3E B6       LD A,#B6
  1831. CCB4 32 5F AB    LD (#AB5F),A
  1832. CCB7 C3 BC F5    JP #F5BC
  1833.  
  1834.  This is the hacking routine which will be copied into the
  1835. loading system. AB5F,B6 is the POKE for infinite lives (which can
  1836. be worked out by a forwards or a backwards trace), and JP #F5BC
  1837. jumps to the game.
  1838.  
  1839.  And that's about it for Bleepload! Hopefully, if you were
  1840. hacking a different game, you still managed to do it (they're all
  1841. virtually identical anyway).
  1842.  
  1843. ULTIMATE LOADER
  1844.  
  1845.  Remember Ultimate? They were one of the finest software houses
  1846. of all time. Most of their games from 1983 to 1987 had the same
  1847. type of loader (but a few were Speedlocked - more about them
  1848. later). On the face of it, it just looks like a totally
  1849. unprotected BASIC loader, but the appearance is deceptive. The
  1850. five blocks it loads are the loading screen, the game itself, a
  1851. decrypter at #5B80, and two very short blocks of system
  1852. variables. The system variables are, in actual fact the BASIC
  1853. clock, and determine how many 50ths of a second the computer has
  1854. been switched on for. The decrypter works using this system
  1855. variable. The upshot of all this is that if you stop the program
  1856. for even 1/50th of a second, you'll mess up the decrypter. You
  1857. can get round this with a Multiface by loading in the first three
  1858. blocks of code, then replacing the code at #5B80 with #F3,#18 and
  1859. #FE. This disables interrupts, so the system variable doesn't get
  1860. updated, and causes an endless loop. Load in the last two blocks,
  1861. activate the Multiface, and find out what the system variable
  1862. should be. Then you can put this into the decrypter
  1863. automatically.
  1864.  
  1865. MIKRO-GEN LOADER
  1866.  
  1867.  This loading system appeared on just about every game released
  1868. by the software house Mikro-Gen (oddly enough!) from about mid-84
  1869. to their demise in 1987. They come in two varieties, and you'll
  1870. need a Multiface to hack some of the later ones, unfortunately.
  1871.  The first type are recognised by black and white loading
  1872. stripes, which loads in a screen block, and then the main game
  1873. block separately. I'll be doing Pyjamarama as an example, but any
  1874. Mikro Gen game which fits the above description will do.
  1875.  
  1876. So the first thing to do is to *Hack the BASIC loader.
  1877.  
  1878. PYJAMARAMA LINE 0 LEN 504
  1879.  
  1880. 0 BORDER 7:PAPER 7:INK 0:BRIGHT 0:FLASH 0:CLS:PRINT AT
  1881. 12,12;"LOADING":RANDOMIZE USR (PEEK 23627+256*PEEK 23628+6)
  1882. 20 POKE 23756,0:POKE 23757,0:SAVE "PYJAMARAMA" LINE 0:RANDOMIZE
  1883. USR 33040
  1884.  
  1885.  The BASIC loader actually features much more than what we can
  1886. list. If you're old enough to remember the ZX81, you'll recall
  1887. that the best place to put a machine code program is in a REM
  1888. statement. And that's almost the case here, except the machine
  1889. code comes after the ASCII code #0D (newline), so you can't list
  1890. it. But it's there. It's activated by the RANDOMIZE USR command.
  1891. Type PRINT (PEEK 23627+256*PEEK 23628+6) and you'll find out the
  1892. start address of the code. I made it 23984, which is 5DB0 hex
  1893. (but you might find it to be something different), so disassemble
  1894. this address.
  1895.  
  1896.  
  1897. 5DB0 F3           DI
  1898. 5DB1 31 00 00     LD SP,#0000
  1899. 5DB4 2A 4B 5C     LD HL,(#5C4B)
  1900. 5DB7 11 1C 00     LD DE,#001C
  1901. 5DBA 19           ADD HL,DE
  1902. 5DBB 11 16 80     LD DE,8016
  1903. 5DBE 01 E7 00     LD BC,00E7
  1904. 5DC1 ED B0        LDIR
  1905. 5DC3 C3 16 80     JP 8016
  1906.  
  1907.  Hopefully the DI and the LD SP,#0000 should be familiar. The
  1908. next line loads HL with the two byte value starting at 5C4B. I
  1909. made it 5DAA. This then has 1C added onto it, making it 5DC6. The
  1910. rest of the code is a simple LDIR command, which puts the loading
  1911. system to where it should be.
  1912.  In our hack, we can simply use a headerless loader to load the
  1913. code into place. We know that 5DC6 goes to 8016. BASIC always
  1914. starts at the value in #5C53, which is #5CCB in this case. We
  1915. know that the length is 504, or #1F8 hex bytes long, and the
  1916. start address is (#5CCB-#5DC6)+8016 = #7F1B. So, run the
  1917. following routine.
  1918.  
  1919. 5B00 DD 21 1B 7F LD IX,#7F1B
  1920. 5B04 11 F8 01    LD DE,#01F8
  1921. 5B07 3E FF       LD A,#FF
  1922. 5B09 37          SCF
  1923. 5B0A CD 56 05    CALL #0556
  1924. 5B0D 30 F1       JR NC,#5B00
  1925. 5B0F C9          RET
  1926.  
  1927.  I've put a JR NC,#5B00 in, so that the computer ignores the
  1928. BASIC header, and will only return on loading the main BASIC
  1929. block. You should also note, that in the final hack, we'll have
  1930. to add a DI and a LD SP,#0000 sometime. For now, disassemble
  1931. #8016
  1932.  
  1933. 8016 DD 21 00 40 LD IX,#4000
  1934. 801A 11 01 1B    LD DE,#1B01
  1935. 801D CD 4F 80    CALL #804F
  1936.  
  1937.  This code activates the turboloader, which loads in the title
  1938. screen.
  1939.  
  1940. 8020 21 00 40    LD HL,#4000
  1941. 8023 01 00 1B    LD BC,#1B00
  1942. 8026 CD 3F 80    CALL #803F
  1943.  
  1944.  This code verifies that the screen has loaded in properly
  1945. (the routine at #803F adds up all the memory with start HL and
  1946. length BC, and compares it with the byte after this block), and
  1947. resets the computer if it hasn't.
  1948.  
  1949. 8029 DD 21 00 82 LD IX,#8200
  1950. 802D 11 A0 7A    LD DE,#7AA0
  1951. 8030 CD 4F 80    CALL #804F
  1952. 8033 21 00 82    LD HL,#8200
  1953. 8036 01 9F 7A    LD BC,#7A9F
  1954. 8039 CD 3F 80    CALL #803F
  1955.  
  1956.  This is exactly the same as with the previous code, except it
  1957. loads and checks the main game instead of the loading screen.
  1958.  
  1959. 803C C3 89 FC    JP #FC89
  1960.  
  1961.  Put a breakpoint over this instruction. Now POKE #8012 with F3,
  1962. #8013 with #31, #8014 with #00 and #8015 with #00 (because we
  1963. didn't execute the DI:LD SP,#0000 from the BASIC loader, and the
  1964. game will not load otherwise), JP #8012 and start the tape. When
  1965. the main game's loaded, disassemble #FC89.
  1966.  
  1967. FC89 21 EF B4    LD HL,#B4EF
  1968. FC8C 11 00 40    LD DE,#4000
  1969. FC8F 01 00 1B    LD BC,#1B00
  1970. FC92 1A          LD A,(DE)
  1971. FC93 AE          XOR (HL)
  1972. FC94 77          LD (HL),A
  1973. FC95 23          INC HL
  1974. FC96 13          INC DE
  1975. FC97 0B          DEC BC
  1976. FC98 78          LD A,B
  1977. FC99 B1          OR C
  1978. FC9A 20 F6       JR NZ,#FC92
  1979. FC9C C3 EA BE    JP #BEEA
  1980.  
  1981.  This decrypter uses values in the screen memory, so you'll have
  1982. to put a breakpoint at FC9C, put a JP #FC89 at #8029, JP to #8012
  1983. and reload the loading screen before you can run it. Then
  1984. disassemble #BEEA.
  1985.  
  1986. BEEA 31 00 00    LD SP,#0000
  1987. BEED CD CC BE    CALL #BECC
  1988. BEF0 C3 00 82    JP #8200
  1989.  
  1990.  This code puts the stack pointer back at #0000, CALLs another
  1991. decrypter, and JPs to #8200, which is the start of the game.
  1992. Change the #8200 to a suitable place to put POKEs; finish them
  1993. with a JP #8200 to start the game.
  1994.  
  1995.  Here's the final hack, and I've put it at #5B00, because it
  1996. doesn't get overloaded, apart from the byte at #5B00 itself,
  1997. which is no longer needed by that time. Also, I've executed the
  1998. DI:LD SP,#0000 directly, as well as the code from BEEA to BEF2.
  1999.  
  2000. 5B00 DD 21 1B 7F LD IX,#7F1B
  2001. 5B04 11 F8 01    LD DE,#01F8
  2002. 5B07 3E FF       LD A,#FF
  2003. 5B09 37          SCF
  2004. 5B0A CD 56 05    CALL #0556
  2005. 5B0D 30 F1       JR NC,#5B00
  2006. 5B0F 21 1C 5B    LD HL,#5B1C
  2007. 5B12 22 3D 80    LD (#803D),HL
  2008. 5B15 F3          DI
  2009. 5B16 31 00 00    LD SP,#0000
  2010. 5B19 C3 16 80    JP #8016
  2011. 5B1C 21 25 5B    LD HL,#5B25
  2012. 5B1F 22 9D FC    LD (#FC9D),HL
  2013. 5B22 C3 89 FC    JP #FC89
  2014. 5B25 31 00 00    LD SP,#0000
  2015. 5B28 CD CC BE    CALL #BECC
  2016. 5B2B AF          XOR A
  2017. 5B2C 32 ?? ??    LD (????),A
  2018. 5B2F C3 00 82    JP #8200
  2019.  
  2020.  The other type of Mikro Gen loader is almost identical, except
  2021. the whole game loads in one long block. Then end of the BASIC
  2022. loading system is missing to start with, and is only loaded right
  2023. at the end of the main headerless block. You can find out the
  2024. missing code by loading the game as normal, then stopping it with
  2025. a Multiface in the pause between the game loading, and the game
  2026. starting (approx. 3 seconds), and hack it in the same way as
  2027. Pyjamarama.
  2028.  
  2029. POWERLOAD
  2030.  
  2031.  This protection system appeared first around the start of 1984,
  2032. and was written by "Tag" (Phil Taglione) for Incentive Software.
  2033. However, it's been used by quite a lot of other software
  2034. companies as well, including Beyond, Mirrorsoft, Prism and
  2035. Ariolasoft. It can be recognised by the screen turning black,
  2036. accompnied by a few ascending beeps. It then loads one short
  2037. headerless block, and then a longer headerless block, which
  2038. includes the attribute file for the game coming up "backwards"
  2039. ie: right to left, starting from the bottom. The game also stops
  2040. loading just before the end of the long headerless block.
  2041.  The only thing I know of that YS have put on the covertape that
  2042. has Powerload is the Graphic Adventure Creator, but that's
  2043. pointless hacking, so instead I'll be hacking Dynamite Dan. Of
  2044. course, most other Powerload games are identical apart from some
  2045. addresses, and, in fact, the BASIC loaders are all identical.
  2046.  
  2047.  Before we start, I need to explain a little more about the
  2048. stack, because Powerload uses it a lot. There are four commands
  2049. which use the stack, and they are:
  2050.  
  2051. PUSH X (where X is any register) - this takes the value in a
  2052. register, and puts it onto the stack. The stack pointer then
  2053. decreases by two (to be in the right place to store another
  2054. value).
  2055.  
  2056. POP X - this takes the two byte value at the stack pointer (ie:
  2057. the top of the stack), and puts them in a register. This also
  2058. increases the stack pointer by two.
  2059.  
  2060. CALL XXXX - when you CALL a subroutine, the return address (ie:
  2061. the address after the call) is PUSHed onto the stack, and the
  2062. subroutine is JPed to. The stack pointer also decreases by two.
  2063.  
  2064. RET - when a RET instruction occurs, the computer takes the value
  2065. on the top of the stack, and JPs to it. The stack pointer
  2066. increases by two.
  2067.  
  2068.  Now we've cleared that up, let's start hacking. *Hack the BASIC
  2069. as usual.
  2070.  
  2071. D.D. LINE 0 LEN 496
  2072.  
  2073. 0 REM
  2074. 10 CLEAR 59999:POKE 23693,0:POKE 23624,0:POKE 23697,0:CLS:POKE
  2075. 23659,0:FOR N=30 TO 36:BEEP .075,N:NEXT N:RANDOMIZE USR
  2076. 24146:RANDOMIZE USR 0
  2077. 100 REM
  2078.  
  2079.  The POKEs in line 10 just make the screen black and prevent you
  2080. from pressing break. 24146 is #5E52 hex; but a breakpoint at
  2081. #5E52 and GOTO 0. This is because the stack is set up in a
  2082. specific way by the BASIC commands.
  2083.  
  2084. 5E52 F3          DI
  2085. 5E53 21 00 00    LD HL,#0000
  2086. 5E56 39          ADD HL,SP
  2087. 5E57 22 F2 5D    LD (#5DF2),HL
  2088.  
  2089.  This code simply puts the value of the stack pointer into
  2090. address #5DF2, so it can be retreived later.
  2091.  
  2092. 5E5A 31 95 5E    LD SP,#5E95
  2093. 5E5D 26 5E       LD H,#5E
  2094. 5E5F E5          PUSH HL
  2095. 5E60 21 68 5E    LD HL,#5E68
  2096. 5E63 E9          JP (HL)
  2097.  
  2098. 5E68 3E 12       LD A,#12
  2099. 5E6A 32 93 53    LD (#5E93),A
  2100. 5E6D E1          POP HL
  2101. 5E6E E5          PUSH HL
  2102. 5E6F D1          POP DE
  2103. 5E70 C9          RET
  2104.  
  2105.  Put a breakpoint at 5E70 and JP to 5E52. At 5E70, the value on
  2106. the top of the stack is #5E76, so a RET will JP to there.
  2107.  
  2108. 5E76 C1          POP BC
  2109. 5E77 7E          LD A,(HL)
  2110. 5E78 ED 44       NEG
  2111. 5E7A 77          LD (HL),A
  2112. 5E7B 23          INC HL
  2113. 5E7C 10 F9       DJNZ #5E77
  2114.  
  2115.  This code is, as you might realise, a decrypter. The start value
  2116. of HL is #5E12, and the initial value of B is #3A. In case you're
  2117. interested, the NEG instruction turns the value in the A register
  2118. into its negative form; in other words, the value in A is
  2119. subtracted from #100 hex. Put a breakpoint at #5E7E and JP #5E70
  2120. (which is where we left off).
  2121.  
  2122. 5E7E E1          POP HL
  2123. 5E7F 22 78 5E    LD (#5E78),HL
  2124. 5E82 C1          POP BC
  2125. 5E83 3E C9       LD A,#C9
  2126. 5E85 32 7E 5E    LD (#5E7E),A
  2127. 5E88 3E 00       LD A,#00
  2128. 5E8A 32 7A 5E    LD (#5E7A),A
  2129. 5E8D 5D          PUSH DE
  2130. 5E8E E1          POP HL
  2131. 5E8F C9          RET
  2132.  
  2133.  This code changes the previous decrypter slightly, and RETs to
  2134. 5E77. Put a breakpoint at 5E8F and JP #5E7E.
  2135.  
  2136. 5E77 7E          LD A,(HL)
  2137. 5E78 ED 67       RRD
  2138. 5E7A 00          NOP
  2139. 5E7B 23          INC HL
  2140. 5E7C 10 F9       DJNZ,#5E77
  2141. 5E7E C9          RET
  2142.  
  2143.  This code works with the same values as the previous one;
  2144. HL=5E12 and B=3A. It then RETs to 5E12. Put a breakpoint at
  2145. #5E7E, and JP #5E8F (where we left off last time).
  2146.  
  2147. 5E12 21 B4 5F    LD HL,#5FB4
  2148. 5E15 11 B5 5F    LD DE,#5FB5
  2149. 5E18 01 B8 88    LD BC,#88B8
  2150. 5E1B ED B0       LDIR
  2151. 5E1D E1          POP HL
  2152. 5E1E 54          LD D,H
  2153. 5E1F 5D          LD E,L
  2154. 5E20 1C          INC E
  2155. 5E21 C1          POP BC
  2156. 5E22 ED B0       LDIR
  2157.  
  2158.  These two LDIR commands wipe all the memory that isn't being
  2159. used by the loading system. To get round this, you should change
  2160. #5E1B, #5E1C, #5E22 and #5E23 to #00, to stop them being
  2161. executed. Put a breakpoint at #5E24 and JP #5E7E (where we left
  2162. off).
  2163.  
  2164. 5E24 06 1E       LD B,#1E
  2165. 5E26 E1          POP HL
  2166. 5E27 7E          LD A,(HL)
  2167. 5E28 EE A3       XOR #A3
  2168. 5E2A 77          LD (HL),A
  2169. 5E2B 23          INC HL
  2170. 5E2C 10 F9       DJNZ,5E27
  2171.  
  2172.  The value in HL for this decrypter is #5E2E, which is right
  2173. after the decrypter. To crack it, therefore, move the code from
  2174. #5E24 to #5E2D somewhere safe (such as #5B00), put a breakpoint
  2175. on the end, and run the code from there. When that's done, put a
  2176. breakpoint at #5E2E and JP to #5E2E (so that you're back in the
  2177. right place in the loading system).
  2178.  Carrying on with the loader....
  2179.  
  2180. 5E2E E1          POP HL
  2181. 5E2F 22 02 5E    LD (#5E02),HL
  2182. 5E32 E1          POP HL
  2183. 5E33 22 05 5E    LD (#5E05),HL
  2184. 5E36 37          SCF
  2185. 5E37 3E 07       LD A,#07
  2186. 5E39 CD 00 5E    CALL #5E00
  2187.  
  2188.  This code takes some values off the stack, and puts them into
  2189. the subroutine at #5E00, which is then CALLed. Put a breakpoint
  2190. at #5E39 and JP to #5E2E.
  2191.  
  2192. 5E00 DD 21 40 9C LD IX,#9C40
  2193. 5E04 11 90 1     LD DE,#190
  2194. 5E07 14          INC D
  2195. 5E08 08          EX AF,AF'
  2196. 5E09 15          DEC D
  2197. 5E0A 3E 0F       LD A,#0F
  2198. 5E0C DB FE       OUT (#FE),A
  2199. 5E0E CD 62 05    CALL #0562
  2200. 5E11 C9          RET
  2201.  
  2202.  This routine is a headerless loader. The start is #9C40 and the
  2203. length is #190. Also the value of A is 7, and the carry flag has
  2204. been set. In effect, we could have used a standard CALL #0556
  2205. headerless loader. Put a breakpoint at #5E3C and JP to #5E39.
  2206. Start the tape and load in the first short headerless block. Then
  2207. continue disassembling.
  2208.  
  2209. 5E3C D2 01 00    JP NC,#0001
  2210.  
  2211.  This code resets the computer if there was a loading error from
  2212. the first headerless block.
  2213.  
  2214. 5E3F 21 40 9C    LD HL,#9C40
  2215. 5E42 06 FF       LD B,#FF
  2216. 5E44 CD 77 5E    CALL #5E77
  2217. 5E47 06 FF       LD B,#FF
  2218. 5E49 CD 77 5E    CALL #5E77
  2219. 5E4C F3          DI
  2220. 5E4D C9          RET
  2221.  
  2222.  This code decrypts the headerless file we have just loaded in.
  2223. The decrypter is CALLed to, and it's the same one we had before
  2224. (with the RRD). So, in actual fact, we can forget about the BASIC
  2225. loader; just load in the headerless file normally and run our own
  2226. decrypter. For now, just put a breakpoint at #5E4D and JP to
  2227. #5E3F. The RET is to #9C40
  2228.  
  2229. 9C40 21 52 9C    LD HL,#9C52
  2230. 9C43 01 90 01    LD BC,#0190
  2231. 9C46 16 A5       LD D,#A5
  2232. 9C48 7E          LD A,(HL)
  2233. 9C49 AA          XOR D
  2234. 9C4A 77          LD (HL),A
  2235. 9C4B 23          INC HL
  2236. 9C4C 0B          DEC BC
  2237. 9C4D 78          LD A,B
  2238. 9C4E B1          OR C
  2239. 9C4F C2 48 9C    JP NZ,9C48
  2240.  
  2241.  This is a decrypter, and you can crack it in one of two ways.
  2242. Firstly, you can copy if to somewhere else, put a breakpoint on
  2243. the end, and run it from there, or you can replace the JP NZ,9C48
  2244. with JR NZ,9C48. Both do the same thing, but the JR NZ only uses
  2245. two bytes. This means we can put a RET at #9C51 and CALL the
  2246. decrypter. So change #9C4F to #20, #9C50 to #F7 and #9C51 to #C9,
  2247. then put a CALL #9C40 and a breakpoint somewhere convenient (such
  2248. as #5B00) and run the decrypter from there. When decrypted, the
  2249. code continues at #9C52.
  2250.  
  2251. 9C52 21 63 9C    LD HL,#9C63
  2252. 9C55 11 45 FE    LD DE,#FE45
  2253. 9C58 01 90 01    LD BC,#0190
  2254. 9C5B ED B0       LDIR
  2255. 9C5D 31 84 FD    LD SP,#FD84
  2256. 9C60 C3 45 FE    JP #FE45
  2257.  
  2258.  This moves the code we've just decrypted to #FE45, sets the
  2259. stack pointer to #FD84, and JPs to #FE45. Put a breakpoint at
  2260. #9C60 and JP to #9C52.
  2261.  
  2262. Now at #FE45, we come to the actual loading system itself.
  2263.  
  2264. FE45 3E 84       LD A,#84
  2265. FE47 11 00 18    LD DE,#1800
  2266. FE4A DD 21 00 40 LD IX,#4000
  2267. FE4E CD AB FE    CALL #FEAB
  2268.  
  2269.  This code loads in a headerless file with start #4000 and length
  2270. #1800 (which is the display file for the screen). Nothing too
  2271. unusual about that.....
  2272.  
  2273. FE51 11 00 04    LD DE,#0400
  2274. FE54 DD 21 FF 5B LD IX,#5BFF
  2275. FE58 CD 2A FF    CALL #FF2A
  2276.  
  2277. ....except that as soon as it's done that,it loads in a block
  2278. with start #5BFF and length #0400 straight away. This block is
  2279. "sandwiched" right next to the other block on the tape. This
  2280. particular block loads "backwards".
  2281.  
  2282. FE5B 11 E1 01    LD DE,#01E1
  2283. FE5E DD 21 1F FE LD IX,#FE1F
  2284. FE62 CD FA FA    CALL #FEFA
  2285.  
  2286.  And here's another block of the same kind, except it's loaded
  2287. forwards this time. What's worse is that it's going to overwrite
  2288. the code we're looking at now, so it must be a "modification" to
  2289. the loading system (similar to the Mikro-Gen loader). To get
  2290. round this, we would have to copy the code somewhere else, stick
  2291. a breakpoint on the end, and run it from there. But remember that
  2292. the loading system was copied from address #9C63, so there is, in
  2293. actual fact, a copy of the code anyway. You want to put a
  2294. breakpoint at #9C83 (the instruction after loading these three
  2295. blocks), and JP to #9C63. Then start the tape and load in the
  2296. next headerless block. The loading screen will appear, and the
  2297. game will load for about four seconds, then control will return
  2298. to the disassembler. Now look at the code at #FE65.
  2299.  
  2300. FE65 11 1D 9F    LD DE,#9F1D
  2301. FE68 DD 21 1C FA LD IX,#FA1C
  2302. FE6C CD 2A FF    CALL #FF2A
  2303.  
  2304.  This code loads the main game backwards. This will overwrite
  2305. your disassembler, so you will have to put the NEW routine at
  2306. #FE6F (but write down all the bytes you are replacing, because
  2307. you'll need to restore all the original code later). Then you
  2308. will have to go back and load the first block, because there
  2309. isn't a header for the main game block. Change #FE4D to #01,
  2310. #FE57 to #10 and #FE61 to #01 - this will make the computer try
  2311. to load the three blocks into the ROM. Then rewind the tape back
  2312. to the start of this headerless block, JP #FE45, and start the
  2313. tape. Upond loading the whole block, the computer will reset.
  2314. Load in your disassembler, and replace the code from the NEW
  2315. routine to the values they should be. Now you can tackle the
  2316. final part of the loading system.
  2317.  
  2318. FE6F 11 E4 12    LD DE,#12E4
  2319. FE72 DD 21 FF FF LD IX,#FFFF
  2320. FE76 C3 70 FF    JP #FF70
  2321.  
  2322. FF70 3E 00       LD A,0
  2323. FF72 D3 FE       OUT (#FE),A
  2324. FF74 CD 1F FE    CALL #FE1F
  2325. FF77 21 43 FE    LD HL,#FE43
  2326. FF7A BE          CP (HL)
  2327. FF7B CA 89 FF    JP Z,#FF89
  2328. FF7E 21 48 EE    LD HL,#EE48
  2329. FF81 01 FF FF    LD BC,#FFFF
  2330. FF84 11 49 EE    LD DE,#EE49
  2331. FF87 ED B0       LDIR
  2332.  
  2333.  The routine at #FE1F adds up all the memory in the screen to get
  2334. a value in the D register. This is then compared with the value
  2335. of the byte at #FE43. If there is no match, all the memory is
  2336. blanked out, so the value in the D register must be the same as
  2337. the byte at #FE43. You should find that the byte is #E6. You need
  2338. to know this for later on.
  2339.  
  2340. FF89 21 A3 FF    LD HL,#FFA3
  2341. FF8C 01 45 00    LD BC,#0045
  2342. FF8F 7A          LD A,D
  2343. FF90 AE          XOR (HL)
  2344. FF92 23          INC HL
  2345. FF93 0B          DEC BC
  2346. FF94 78          LD A,B
  2347. FF95 B1          OR C
  2348. FF96 C2 8F FF    JP NZ,#FF8F
  2349.  
  2350.  This is all we can disassemble for the moment, because the code
  2351. from #FF89 to #FF98 decrypts the final part of the loader. Change
  2352. the byte at #FF87 to #16, and the byte at #FF88 to #E6 (this is
  2353. LD D,#E6, which is used in the decrypter), put a breakpoint at
  2354. #FF99, and JP to #FF87. Then continue the disassembly.
  2355.  
  2356. FF99 CD 31 FE    CALL #FE31
  2357. FF9C 21 44 FE    LD HL,#FE44
  2358. FF9F BE          CP (HL)
  2359. FFA0 C2 7E FF    JP NZ,#FF7E
  2360.  
  2361.  This code checks the main game, coming out with a result in the
  2362. E register. However, this value is never used, so you can ignore
  2363. this whole routine.
  2364.  Following on.....
  2365.  
  2366. FFA3 21 C0 5D    LD HL,#5DC0
  2367. FFA6 01 30 75    LD BC,#7530
  2368. FFA9 CD D4 FF    CALL #FFD4
  2369. FFAC 21 C0 5D    LD HL,#5DC0
  2370. FFAF 01 30 75    LD BC,#7530
  2371. FFB2 CD DE FF    CALL #FFDE
  2372. FFB5 21 1C FA    LD HL,#FA1C
  2373. FFB8 11 1C FF    LD DE,#FF1C
  2374. FFBB 01 1D 9F    LD BC,#9F1D
  2375. FFBE ED B8       LDIR
  2376. FFC0 21 10 A7    LD HL,#A710
  2377. FFC3 22 36 5C    LD (#5C36),HL
  2378. FFC6 01 10 DF    LD BC,#DF10
  2379. FFC9 AF          XOR A
  2380. FFCA ED 42       SBC HL,BC
  2381. FFCC 31 FF FF    LD SP,FFFF
  2382. FFCF ED 56       IM1
  2383. FFD1 C3 6F 00    JP #006F
  2384.  
  2385. 006F E9          JP (HL)
  2386.  
  2387.  This routine runs the game decrypters, moves the game into the
  2388. right place, sets the stack and the interrupts, and puts the
  2389. start address for the game in the HL register. Change the #006F
  2390. at #FFD2 to somewhere where you can put a NEW routine (such as
  2391. #5B00), because the disassembler will be overwritten. Then,
  2392. change the value at #FFA1 to 16, and the value at #FFA2 to #E6
  2393. (because one decrypter uses the value in the D register), and JP
  2394. to #FFA2. When that's done, you can reload your disassembler, and
  2395. hack the game using a forwards and backwards trace (but you won't
  2396. be able to run the code because some of it's missing!)
  2397.  
  2398.  Now we'll write a complete hack for the game. You have to be a
  2399. bit careful about where you put your hack in memory, because a
  2400. lot of memory is overloaded. The first free address we can put
  2401. the code at is #FA1D.
  2402.  
  2403. FA1D DD 21 40 9C LD IX,#9C40
  2404. FA21 11 90 01    LD DE,#0190
  2405. FA24 3E 07       LD A,#07
  2406. FA26 37          SCF
  2407. FA27 CD 56 05    CALL #0556
  2408. FA2A 30 F1       JR NC,#FA1D
  2409.  
  2410.  This loads in the first headerless block using the values set up
  2411. in the BASIC loader.
  2412.  
  2413. FA2C 06 FF       LD B,#FF
  2414. FA2E 21 40 9C    LD HL,#9C40
  2415. FA31 7E          LD A,(HL)
  2416. FA32 ED 67       RRD
  2417. FA34 23          INC HL
  2418. FA35 10 FA       DJNZ #FA31
  2419. FA37 06 FF       LD B,#FF
  2420. FA39 7E          LD A,(HL)
  2421. FA3A ED 67       RRD
  2422. FA3C 23          INC HL
  2423. FA3D 10 FA       DJNZ, #FA39
  2424.  
  2425. This decrypts the headerless block.
  2426.  
  2427. FA3F 21 20 F7    LD HL,#F720
  2428. FA42 22 4F 9C    LD (#9C4F),HL
  2429. FA45 3E C9       LD A,#C9
  2430. FA46 32 51 9C    LD (#9C51),A
  2431. FA49 CD 40 9C    CALL #9C40
  2432.  
  2433.  This changes the JP NZ at #9C4F to a JR NZ and a RET, then calls
  2434. the decrypter.
  2435.  
  2436. FA4C 3E C3       LD A,#C3
  2437. FA4E 32 83 9C    LD (#9C83),A
  2438. FA51 21 5A FA    LD HL,#FA5A
  2439. FA54 22 84 9C    LD (#9C84),HL
  2440. FA57 C3 63 9C    JP #9C63
  2441.  
  2442.  This puts a JP back to our hack at #9C83, and jumps to #9C63 to
  2443. load the first part of the headerless block.
  2444.  
  2445. FA5A 3E C9       LD A,#C9
  2446. FA5C 32 6F FE    LD (#FE6F),A
  2447. FA5F CD 65 FE    CALL #FE65
  2448.  
  2449.  This puts a RET after the code to load the rest of the game,
  2450. then CALLs that loading procedure.
  2451.  
  2452.  
  2453. FA62 21 E6 16    LD HL,#16E6
  2454. FA65 22 87 FF    LD (#FF87),HL
  2455. FA68 3E C9       LD A,#C9
  2456. FA6A 32 99 FF    LD (#FF99),A
  2457. FA6D CD 87 FF    CALL #FF87
  2458.  
  2459.  This patches in the LD D,#E6, puts a RET at the end of the
  2460. decrypter, and CALLs it.
  2461.  
  2462. FA70 21 7E FA    LD HL,#FA7E
  2463. FA73 11 00 40    LD DE,#4000
  2464. FA76 01 20 00    LD BC,#0020
  2465. FA79 ED B0       LDIR
  2466. FA7B C3 00 40    JP #4000
  2467.  
  2468.  This code moves our hack into the screen memory (so it isn't
  2469. affected by the LDIR which overwrites it in the next bit of
  2470. code), and jumps to it there.
  2471.  
  2472. FA7E 21 0B 40    LD HL,#400B
  2473. FA81 22 D2 FF    LD (#FFD2),HL
  2474. FA84 16 E6       LD D,#E6
  2475. FA86 C3 A3 FF    JP #FFA3
  2476.  
  2477.  This code replaces the JP #006F with a JP back to our hack
  2478. (which is in the screen memory by this time), and JPs to #FFA3.
  2479. We have to include the LD D,#E6 again, because the value of DE
  2480. was corrupted by the LDIR.
  2481.  
  2482. FA89 AF          XOR A
  2483. FA8A 32 C6 CD    LD (#CDC6),A
  2484. FA8D E9          JP (HL)
  2485.  
  2486.  This sets the infinite lives POKE, and does a JP (HL) to start
  2487. the game.
  2488.  
  2489.  Phew! I hope you managed to get all that, because it's really
  2490. hard to do without a Multiface. If you can do it, then you've
  2491. definitely got the hang of things, so keep it up!
  2492.  
  2493. SEARCH LOADER
  2494.  
  2495.  This loading system appears on every game ever written by Steve
  2496. Marsden (who wrote the original loading system), as well as a few
  2497. others. You can recognise them by their fancy front end, which
  2498. consists of a countdown timer, accompnied by animated graphics
  2499. and/or instructions, which appear as the game loads. The only
  2500. game I've actually got at the moment that's got a Search Loader
  2501. on it is Technician Ted, so I'm going to have to hack that.
  2502.  
  2503.  So, *Hack the BASIC loader, and let's see what it's got to
  2504. offer....
  2505.  
  2506. Chip Fact LINE 0 LEN 736
  2507.  
  2508. 0 RANDOMIZE USR 24341
  2509.  
  2510.  The rest of the BASIC is a load of garbage which consists of the
  2511. machine code for the game. It is stored in a similar way to that
  2512. in the Mikro Gen loader. 24341 is 5F15 hex, so disassemble this
  2513. address.
  2514.  
  2515. 5F15 F3          DI
  2516. 5F16 21 00 40    LD HL,#4000
  2517. 5F19 11 01 40    LD DE,#4001
  2518. 5F1C 01 FF 17    LD BC,#17FF
  2519. 5F1F 36 00       LD (HL),0
  2520. 5F21 ED B0       LDIR
  2521.  
  2522. This code blanks out the screen.
  2523.  
  2524. 5F23 CD 32 5E    CALL #5E32
  2525.  
  2526.  The routine at #5E32 sets up the attributes for the screen ie:
  2527. red banners at the top and bottom, black background with varying
  2528. ink colours in the middle.
  2529.  
  2530. 5F26 C3 38 5F    JP #5F38
  2531.  
  2532. 5F38 21 AB 5F    LD HL,#5FAB
  2533. 5F3B 01 59 A0    LD BC,#A059
  2534. 5F3E 31 00 5C    LD SP,#5C00
  2535. 5F41 3A A8 5F    LD A,(#5FA8)
  2536. 5F44 57          LD D,A
  2537. 5F45 1E 0B       LD E,#0B
  2538. 5F47 7A          LD A,D
  2539. 5F48 87          ADD A,A
  2540. 5F49 87          ADD A,A
  2541. 5F4A 87          ADD A,A
  2542. 5F4B 87          ADD A,A
  2543. 5F4C 82          ADD A,D
  2544. 5F4D 83          ADD A,E
  2545. 5F4E 57          LD D,A
  2546. 5F4F 77          LD (HL),A
  2547. 5F50 23          INC HL
  2548. 5F51 0B          DEC BC
  2549. 5F52 78          LD A,B
  2550. 5F53 B1          OR C
  2551. 5F54 20 F1       JR NZ,#5F47
  2552.  
  2553.  This routine fills all of the memory above #5FAB with
  2554. unexecutable code. It is, however, extremely important code, as
  2555. we shall see later on.
  2556.  
  2557. 5F56 CD 93 5F    CALL #5F93
  2558.  
  2559.  This routine at #5F93 just messes around with the garbage a bit
  2560. more.
  2561.  
  2562. 5F59 CD 80 5D    CALL #5D80
  2563.  
  2564.  The routine at #5D80 scrolls in the title messages for the game,
  2565. accompnied by annoying clicks.
  2566.  
  2567. 5F5C 3A 66 80    LD A,(#8066)
  2568. 5F5F 6F          LD L,A
  2569. 5F60 3A E6 60    LD A,(#60E6)
  2570. 5F63 67          LD H,A
  2571. 5F64 E5          PUSH HL
  2572. 5F65 3A 4F FC    LD A,(#FC4F)
  2573. 5F68 5F          LE E,A
  2574. 5F69 3A 0F 60    LD A,(#600F)
  2575. 5F6C 57          LD D,A
  2576. 5F6D DD E1       POP IX
  2577. 5F6F 37          SCF
  2578. 5F70 3E FF       LD A,#FF
  2579. 5F72 14          INC D
  2580. 5F73 08          EX AF,AF'
  2581. 5F74 15          DEC D
  2582. 5F75 3A 66 63    LD A,(#6366)
  2583. 5F78 6F          LD L,A
  2584. 5F79 3A E6 63    LD A,(#63E6)
  2585. 5F7C 67          LD H,A
  2586. 5F7D E5          PUSH HL
  2587. 5F7E DB FE       OUT (#FE),A
  2588. 5F80 1F          RRA
  2589. 5F81 E6 20       AND #20
  2590. 5F83 F6 01       OR #01
  2591. 5F85 4F          LD C,A
  2592. 5F86 BF          CP A
  2593. 5F87 F5          PUSH AF
  2594. 5F88 3A 87 65    LD A,(#6587)
  2595. 5F8B 6F          LD L,A
  2596. 5F8C 3A 85 64    LD A,(#6485)
  2597. 5F8F 67          LD H,A
  2598. 5F90 F1          POP AF
  2599. 5F91 E5          PUSH HL
  2600. 5F92 C9          RET
  2601.  
  2602.  This code takes values out of the garbage and puts them in
  2603. certain registers. It then imitates the start of the ROM loading
  2604. routine, and puts some values on the stack. At #5F92, the values
  2605. of the registers are: Hl= #056B, DE=#03C3, IX=#8000, and the
  2606. values on the stack are first #056B, then #8000. So, this code
  2607. will load a headerless file with start #8000 and length #0363,
  2608. then will JP straight to #8000. We can do away with the BASIC
  2609. loader altogether in the final hack by mimicing the headerless
  2610. loader. This is done using the following program.
  2611.  
  2612. 5B00 F3          DI
  2613. 5B01 31 00 5C    LD SP,#5C00
  2614. 5B04 DD 21 00 80 LD IX,#8000
  2615. 5B08 11 C3 03    LD DE,#03C3
  2616. 5B0B 3E FF       LD A,#FF
  2617. 5B0D 37          SCF
  2618. 5B0E 14          INC D
  2619. 5B0F 08          EX AF,AF'
  2620. 5B10 15          DEC D
  2621. 5B11 AF          XOR A
  2622. 5B12 DB FE       OUT (#FE),A
  2623. 5B14 1F          RRA
  2624. 5B15 E6 20       AND #20
  2625. 5B17 F6 01       OR #01
  2626. 5B19 4F          LD C,A
  2627. 5B1A CD 6B 05    CALL #056B
  2628. 5B1D <breakpoint>
  2629.  
  2630.  This routine is slightly different than the one in the loader
  2631. for two reasons. Firstly, I've put values into the registers
  2632. directly, rather than have their values taken from bytes in
  2633. memory. Secondly, you aren't allowed by law to rip off someone
  2634. else's code; if you directly copied a loading system into a hack,
  2635. you could be sued. In fact, someone was, once! You're probably
  2636. alright copying a five byte decrypter from Powerload across,
  2637. because there really isn't any other code which can do the job in
  2638. the same way. In general, I would say don't copy code into your
  2639. hack unless you have to. If you do, change it if you can so it
  2640. does the same job in a different way. Copying 40 bytes of code
  2641. directly out of a loading system is definitely out, and most
  2642. magazines wouldn't print the routine anyway.
  2643.  There are a few commands we haven't met in the routine. EX AF',
  2644. AF' concerns the swapping of registers. In the Z80, in actual
  2645. fact, there are two different sets of each register, although
  2646. only one set can ever be used at once. Think of it like a TV set,
  2647. although both registers (A and A' in this case) are there, you
  2648. can only see one at a time. EX AF,AF' exchanges both the A
  2649. register and the contents of the flags. Don't worry any more
  2650. about swapping registers for now.
  2651.  RRA rotates all the bits in the A register to the right.
  2652. Actually, it doesn't quite do this, but we don't need to know
  2653. about it.
  2654.  If you're not using a Multiface, the garbage routine will have
  2655. overwritten the disassembler, so reload it in anywhere below
  2656. #8000. Then run the routine and restart the tape from where you
  2657. left off. A small part of the headerless block will load in, and
  2658. control will return to the disassembler. Have a look at address
  2659. #8000.
  2660.  
  2661. 8000 D2 00 00    JP NC,#0000
  2662.  
  2663.  This resets the computer if the previous headerless block didn't
  2664. load properly.
  2665.  
  2666. 8003 3E 08       LD A,#08
  2667. 8005 D3 FE       OUT (#FE),A
  2668.  
  2669.  This makes the border black, and sends a signal to the cassette
  2670. recorder.
  2671.  
  2672. 8007 D9          EXX
  2673.  
  2674.  EXX is a "general exchange" instruction, and changes the
  2675. registers B,C,D,E,H and L for their alternate sets.
  2676.  
  2677. 800E 0E 00       LD C,#00
  2678. 800A D9          EXX
  2679. 800B 26 00       LD H,#00
  2680. 800D 06 80       LD B,#80
  2681. 800F DD 21 1C 8C LD IX,#8C1C
  2682. 8013 16 05       LD D,#05
  2683. 8015 CD 41 83    CALL #8341
  2684. 8018 D2 00 00    JP NC,#0000
  2685. 801B 06 B1       LD B,#B1
  2686. 801D 15          DEC D
  2687. 801E 20 F5       JR NZ,#8015
  2688.  
  2689.  This code loads in five bytes of tape (the routine at #8341
  2690. loads in information off tape into the address pointed to by the
  2691. IX register), starting at #8C1C. Therefore, this tape routine
  2692. will start loading code at #8C1C.
  2693.  
  2694. 8020 11 D8 72    LD DE,#72D8
  2695. 8023 D9          EXX
  2696. 8024 0C          INC C
  2697. 8025 D9          EXX
  2698. 8026 C3 7D 83    JP #837D
  2699.  
  2700. 837D 2E 01       LD L,#01
  2701. 837F CD 41 83    CALL #8341
  2702. 8382 D2 00 00    JP NC,#0000
  2703. 8385 3E CB       LD A,#CB
  2704. 8387 B8          CP B
  2705. 8388 17          RLA
  2706. 8389 D9          EXX
  2707. 838A 47          LD B,A
  2708. 838B E6 01       AND #01
  2709. 838D 3D          INC A
  2710. 838F 11 6B 80    LD DE,#806B
  2711. 8392 1A          LD A,(DE)
  2712. 8393 A7          AND A
  2713. 8394 C4 77 82    CALL NZ,#8277
  2714.  
  2715.  This loads in a set number of bytes from tape, and then prints
  2716. some sprites on screen (the routine at #8277). This produces all
  2717. the men walking forwards and backwards while the game loads.
  2718.  
  2719. 8397 CB 18       RRB
  2720. 8399 D9          EXX
  2721. 839A CB 15       RL L
  2722. 839C 06 B1       LD B,#B1
  2723. 839E 30 DF       JR NC,#837F
  2724. 83A0 7C          LD A,H
  2725. 83A1 AD          XOR L
  2726. 83A2 67          LD H,A
  2727. 83A3 7A          LD A,D
  2728. 83A4 B3          OR E
  2729. 83A5 20 CE       JR NZ,#8375
  2730.  
  2731.  This updates the computer ready to do the next loading and
  2732. animation sequence.
  2733.  
  2734. 83A7 7C          LD A,H
  2735. 83A8 A7          AND A
  2736. 83A9 C2 00 00    JP NZ,#0000
  2737. 83AC 11 2F EC    LD DE,#EC2F
  2738. 83AF 06 EB       LD B,#EB
  2739. 83B1 CD 41 83    CALL #8431
  2740. 83B4 D2 00 00    JP NC,#0000
  2741. 83B7 3E EA       LD A,#EA
  2742. 83B9 B8          CO #0B
  2743. 83BA D2 00 00    JP NC,#0000
  2744. 83BD 42          LD B,D
  2745. 83BE 15          DEC D
  2746. 83BF 1D          DEC E
  2747. 83C0 C2 B1 83    JP NZ,#83B1
  2748.  
  2749.  This loads in some more bytes from tape. When these have
  2750. finished, the computer will continue execution at address #83C3.
  2751. The code beyond this address does nothing except fiddle about
  2752. with registers, so there might as well be nothing there. The
  2753. first bit of useful code will appear at #8C1C, but this hasn't
  2754. been loaded yet. Instead, put a breakpoint at #83C3, move the
  2755. headerless loading routine so the CALL #056B is at #7FFD, and run
  2756. the code from there. Rewind the tape a bit and reload in all of
  2757. the main headerless block. When finished, you'll find the
  2758. following code at #8C1C.
  2759.  
  2760. 8C1C 3E 5C       LD A,#5C
  2761. 8C1E 21 00 40    LD HL,#4000
  2762. 8C21 54          LD D,H
  2763. 8C22 5D          LD E,L
  2764. 8C23 EB          EX DE,HL
  2765. 8C24 4E          LD C,(HL)
  2766. 8C25 23          INC HL
  2767. 8C26 46          LD B,(HL)
  2768. 8C27 23          INC HL
  2769. 8C28 EB          EX DE,HL
  2770. 8C29 09          ADD HL,BC
  2771. 8C2A BA          CP D
  2772. 8C2B 20 F6       JR NZ,8C23
  2773. 8C2D 11 92 5C    LD DE,#5C92
  2774. 8C30 EE 5C       XOR 5C
  2775. 8C32 28 EF       JR Z,#8C23
  2776. 8C34 E5          PUSH HL
  2777.  
  2778.  This routine adds up every single byte in memory to get a value
  2779. in HL, which is pushed onto the stack. This value is important,
  2780. because it is used in decrypting. This is what the garbage was
  2781. all used for - to get the right value. It's impossible to
  2782. calculate it yourself, because any programs you right will mean
  2783. you get the wrong answer. The only way I can think of to get this
  2784. value is to load the game as normal, and stop the game with a
  2785. Multiface as soon as the timer hits 000. Then put a breakpoint at
  2786. #8C35 and return. Wait a few seconds, then reactivate the
  2787. Multiface and have a look at the stack. The first value will be
  2788. #8C35, the second will be the value of HL you want. You should
  2789. find it's #4DBD.
  2790.  Carrying on the disassembly....
  2791.  
  2792. 8C35 21 00 58    LD HL,#5800
  2793. 8C38 11 01 58    LD DE,#5801
  2794. 8C3B 01 FF 02    LD BC,#02FF
  2795. 8C3E 36 00       LD (HL),#00
  2796. 8C40 ED B0       LDIR
  2797. 8C42 E1          POP HL
  2798.  
  2799.  This clears the screen and restores the value of HL, which is
  2800. used for the following decrypter.
  2801.  
  2802. 8C43 11 60 8C    LD DE,#8C60
  2803. 8C46 0E 29       LD C,#29
  2804. 8C48 7C          LD A,H
  2805. 8C49 65          LD H,L
  2806. 8C4A 47          LD B,A
  2807. 8C4B 09          ADD HL,BC
  2808. 8C4C 1A          LD A,(DE)
  2809. 8C4D AD          XOR L
  2810. 8C4E 12          LD (DE),A
  2811. 8C4F 6F          LD L,A
  2812. 8C50 13          INC DE
  2813. 8C51 1A          LD A,(DE)
  2814. 8C52 AC          XOR H
  2815. 8C53 12          LD (DE),A
  2816. 8C54 13          INC DE
  2817. 8C55 CB 7A       BIT 7,D
  2818. 8C57 20 F0       JR NZ,#8C49
  2819. 8C59 FB          EI
  2820. 8C5A 67          LD H,A
  2821. 8C5B 11 70 71    LD DE,#7170
  2822. 8C5E 19          ADD HL,DE
  2823. 8C5F E9          JP (HL)
  2824.  
  2825.  First of all, POKE #8C40, #8C41 and #8C42 with #21, #BD and #4D
  2826. respectively (so you get the right value of HL), put a breakpoint
  2827. at #8C5B (nearest place possible to the JP (HL) that we can place
  2828. a breakpoint), and JP #8C40. On return, the value of HL is #38F5.
  2829. Add this to #7170 (which is what happens in the next two
  2830. commands) to get #AA65. This is the start address of the game. So
  2831. put a JP to your POKEing routine (anywhere from #5B00 to #5BA0 is
  2832. fine) at #8C5B, and finish your POKEs with a JP #AA65.
  2833.  You will have to do a stack trace to find infinite lives in the
  2834. actual game itself. There is a complete hack for this game by
  2835. myself in YS #78, so why not disassemble it and have a look. It's
  2836. slightly different to what we've done in that it intercepts the
  2837. RET at the end of the loading system rather than mimic the first
  2838. headerless loader, and puts a JP back to the hack at #83C3, but
  2839. apart from that, it's more or less everything we'e discussed
  2840. above put together.
  2841.  
  2842. PAUL OWEN'S PROTECTION SYSTEM
  2843.  
  2844.  This has been used on a few Ocean games, but is in fact a
  2845. standard headerless loader in disguise. The value of A to use is
  2846. always #98. Load in the BASIC loader and the first block of code,
  2847. then stop it with a Multiface, and use a stack trace to find out
  2848. the values of IX and DE for each block, and the JP to the game.
  2849.  
  2850. SPEEDLOCK
  2851.  
  2852.  Concluding the look at protection systems, I think it's only
  2853. fitting that we end in quite possible the most famous protection
  2854. system of all time.
  2855.  Speedlock was first written by two guys called David Looker and
  2856. David Aubery Jones around late 1983, although it wasn't
  2857. commercially used until October 1984, on Daley Thompson's
  2858. Decathlon, by which time it had reached it's third version. Since
  2859. then, it has been used by many major sofware companies,
  2860. especially Ocean. Its also gone many modifications, and can be
  2861. split into three distinct generations.
  2862.  I should state at this point that you need to have a Multiface
  2863. to crack most of these Speedlocks, because they completely
  2864. disrupt the operating system which will lock up any disassembler
  2865. which relies on ROM routines. The Multiface relies on its own
  2866. ROM, which isn't affected by the Speedlock code.
  2867.  
  2868. Type 1 - have one or two BASIC loaders, and load the main code
  2869. with the infamous "clicking" leader tones (you know, instead of a
  2870. steady "bleep", they go "blip, blip, blip, blip" a few times).
  2871.  
  2872. Type 2 - have one short BASIC loader, a long CODE block, lots of
  2873. annoying beeps, then a similar loader to Type 1, minus the
  2874. clicking leader tones, plus a countdown timer.
  2875.  
  2876. Type 3 - as for Type 2, except there is just one very long BASIC
  2877. loader. The protection system crashes if a Multiface is left
  2878. switched on. Mazemania on YS #77 covertape used a Type 3.
  2879.  
  2880.  So, let's start at the very beginning (a very good place to
  2881. start) with Type 1. In fact, there are about four different
  2882. difficulty levels of Type 1 Speedlocks; the difficulty goes in
  2883. chronological order (as you might expect).
  2884.  
  2885.  The very first Type Ones were completely different to later
  2886. ones, having the same initialisation routine, but a completely
  2887. standard decrypter. The only differences between this Speedlock
  2888. and an ordinary decrypting loader were its initialisation routine
  2889. and its use of the IY register.
  2890.  
  2891.  We came across index registers when we first met headerless
  2892. loaders. There are, in fact, two index registers, IX and IY. In
  2893. BASIC, the IX register is free for use in a machine code program
  2894. run from a USR command, but the IY register must always contain
  2895. the value #5C3A, which is the base address of the BASIC system
  2896. variables which are wiped with a NEW command. If you return to
  2897. BASIC with the value of IY anything other than #5C3A, the
  2898. computer will crash, even if you use the "exit to BASIC" feature
  2899. on a Multiface. The value of IY must also be #5C3A whenever a
  2900. BASIC interrupt occurs. Both Devpac and 007 Disassembler run
  2901. under the BASIC interrupts. They also use built in ROM routines,
  2902. such as those to check the keyboard and print text; this is
  2903. preferable, otherwise they'd have to waste memory rewriting their
  2904. own versions of the routines. Hence the value of IY must always
  2905. equal #5C3A.
  2906.  The only safe way of using the IY register is to disable
  2907. interrupts and write the whole program in RAM without using any
  2908. built in ROM routines. And Speedlock fits this bill exactly, so
  2909. it uses the IY register for most of its decrypter calculations.
  2910.  Speedlock code also uses a lot of undocumented instructions. In
  2911. theory, you cannot split the sixteen bit IY register into two
  2912. eight bit registers. But the processor doesn't understand this,
  2913. and you can split the IY register into two if you want. You
  2914. simply put the code #FD on the front of any instructions using H
  2915. or L. There are no standard names for the two halves of the IY
  2916. register, but I will refer to them as IYH (Hi part of IY) and IYL
  2917. (Lo part of IY).
  2918.  
  2919.  Now let's hack a Speedlock game. To start with, I'm hacking
  2920. Knight Lore, but the following games are also suitable: Beach
  2921. Head, Daley Thompson's Decathlon, Gilligan's Gold and
  2922. Underwurlde. Anything released after these will be explained
  2923. later.
  2924.  
  2925.  So first *Hack the BASIC loader.
  2926.  
  2927. KNIGHT LINE 0 LEN 1037
  2928.  
  2929. 0 BEEP 0.1,1:BEEP 0.1,2:BEEP 0.1,3:BEEP 0.1,4:BEEP 0.1,5:PAPER
  2930. 0:BORDER 0:INK 0:BRIGHT 1:CLS:PRINT BRIGHT 1;INK 0;AT 9,5;
  2931. "LOADING: KNIGHT LORE";AT 12,10;"PLEASE WAIT"
  2932. 0 POKE (PEEK 23641+256*PEEK 23642),PEEK 23649:POKE (PEEK 23641+
  2933. 256*PEEK 23642)+1,PEEK 23650
  2934. 0 POKE (PEEK 23613+256*PEEK 23614),PEEK 23627:POKE (PEEK 23613+
  2935. 256*PEEK 23614)+1,PEEK 23628
  2936. 0 POKE 23662,PEEK 23618:POKE 23663,PEEK 23619:POKE 23664,PEEK
  2937. 23621
  2938. 23676 "REM CLOSE #ATTR....
  2939.  
  2940.  Wait a minute, there's absolutely no sign of a RANDOMIZE USR
  2941. command anywhere! There's just some BASIC which beeps a bit, sets
  2942. the colours, and prints a message, a whole load of POKEs, and
  2943. then a load of garbage. Surely the computer will do everything,
  2944. then report with an error message as soon as it reaches 23676?
  2945.  Well, that's not actually the case. Look at the third line 0
  2946. (the one which starts POKE [PEEK 23613+256* etc.). This system
  2947. variable is known as ERR SP. What happens is that when an error
  2948. occurs (and it will do here), the computer jumps to the value in
  2949. this register. This value is PEEK 23627+256*PEEK 23628. PRINT
  2950. this value, and there's the start of the machine code. You might
  2951. get a different result to me, but I made the start address #60A8.
  2952. Disassemble this address.
  2953.  
  2954. 60A8 F3          DI
  2955. 60A9 FD 25       DEC IYH
  2956. 60AB FD 7C       LD A,IYH
  2957. 60AD FD AD       XOR IYL
  2958.  
  2959.  The DI is very important, because otherwise the I register can't
  2960. be used. Given that IY starts off as being #5C3A, the value in A
  2961. will end up being #5B XORed with #3A, which is #61.
  2962.  
  2963. 60AF FD 26 F3    LD IYH,#F3
  2964. 60B2 FD 2E A6    LD IYL,#A6
  2965. 60B5 3B          DEC SP
  2966. 60B6 3B          DEC SP
  2967. 60B7 01 54 FE    LD BC,#FE54
  2968. 60BA FD E3       EX (SP),IY
  2969.  
  2970.  First of all, this loads IY with the value #F3A6. It then
  2971. decreases the stack pointer by two. By doing this, the stack
  2972. pointer is now pointing to the start address of the machine code,
  2973. which is #60A8. EX (SP),IY is a variation to the register
  2974. exchange commands we've already come across. It basically swaps
  2975. the value in the address pointed by the stack pointer with the
  2976. value in the IY register. So, after this instruction, IY will
  2977. contain #60A8, and the value on the top of the stack will be
  2978. #F3A6.
  2979.  
  2980. 60BC 21 30 F2    LD HL,#F230
  2981. 60BF FD 09       ADD IY,BC
  2982. 60C1 01 AC 01    LD BC,#01AC
  2983. 60C4 FD 5D       LD E,IYL
  2984. 60C6 FD 54       LD D,IYH
  2985. 60C8 EB          EX DE,HL
  2986.  
  2987.  Here, HL is being loaded with #F230. The value in BC (#FE54) is
  2988. added to the value in IY (#60A8), making the value in IY #5EFC.
  2989. Then BC is loaded with #01AC, and the value in IY is transferred
  2990. into DE. Then the values of DE and HL are swapped. So, by the end
  2991. of the code we've looked at so far, HL will equal #5EFC, DE will
  2992. equal #F230, BC will equal #01AC, and A will equal #61. These
  2993. values are all used in the decrypter which follows.
  2994.  
  2995. 60C9 AE          XOR (HL)
  2996. 60CA 12          LD (DE),A
  2997. 60CB 7E          LD (HL),A
  2998. 60CC 23          INC HL
  2999. 60CD 13          INC DE
  3000. 60CE 0B          DEC BC
  3001. 60CF FD 6F       LD IYL,A
  3002. 60D1 78          LD A,B
  3003. 60D2 B1          OR C
  3004. 60D3 FD 7D       LD A,IYL
  3005. 60D5 20 F2       JR NZ,#60C9
  3006. 60D7 C9          RET
  3007.  
  3008.  This is a straightforward decrypter, except the value for A
  3009. (which is needed throughout the decrypter) is temporarily stored
  3010. in part of the IY register. The RET is to #F3A6 (the top value on
  3011. the stack).
  3012.  To crack this, we can set up the register values manually, CALL
  3013. the decrypter, and then hack the main loader ourselves. Type out
  3014. this program:
  3015.  
  3016. 5B00 F3          DI
  3017. 5B01 21 FC 5E    LD HL,#5EFC
  3018. 5B04 11 30 F2    LD DE,#F230
  3019. 5B07 01 AC 01    LD BC,#01AC
  3020. 5B0A 3E 61       LD A,#61
  3021. 5B0C CD C9 60    CALL #60C9
  3022. 5B0F FD 21 3A 5C LD IY,#5C3A
  3023. 5B13 <breakpoint>
  3024.  
  3025.  Notice that we've disabled interrupts to avoid crashing, and we
  3026. need to restore the value of IY to #5C3A afterwards, so your
  3027. disassembler won't crash. RUN the program, and have a look at the
  3028. code at #F3A6. You'll find it's just a straightforward headerless
  3029. loader with absoultely no frills, and you should be able to hack
  3030. it no problem.
  3031.  As for the final hack, load the BASIC into address #5CCB, run
  3032. the decryption routine above, patch the JP in the main
  3033. turboloader to your POKEs, and start running.
  3034.  
  3035.  All other Speedlock Type 1s have the same sort of decrypter. The
  3036. code for the decrypter is very complicated, with the result that
  3037. I have been unable to reproduce it here. Luckily, you don't have
  3038. to touch the code; you can write your own decrypter as long as
  3039. you have a Multiface.
  3040.  
  3041.  I'll be doing Tapper as an example, but any other Speedlock
  3042. follows this procedure almost exactly. *Hack your game and note
  3043. down the length of the code (you'll need it later). I made it
  3044. 1453, which is #05AD hex. Now look at address #5EFD. The byte at
  3045. #5EFD is always decrypted to give the byte #42, and the byte at
  3046. #5EFD is always decrypted to give the byte #55. The decrypter
  3047. works by XORing the encrypted byte with a number taken from the R
  3048. register. By inspecting the code before and after running, you'll
  3049. see the XORing number starts off as #CB, and increases by #0A
  3050. each time. If the result is more than #FF, the result has #80
  3051. subtracted from it. We can incorporate this into our decrypter.
  3052. The start of the code is #5EFD, and the length is (PEEK 23627+
  3053. 256*PEEK 23628)-#5EFD, which is #01ED in the case of Tapper.
  3054. The following code will simulate the decrypter.
  3055.  
  3056.     LD HL,<start>
  3057.     LD BC,<length>
  3058.     LD D,<initial decrypter value>
  3059. *** LD A,(HL)
  3060.     XOR D
  3061.     LD (HL),A
  3062.     LD A,D
  3063.     ADD #0A
  3064.     SET 7,A
  3065.     LD D,A
  3066.     INC HL
  3067.     DEC BC
  3068.     JR NZ, ***
  3069.  
  3070.  Once you've done that decrypter, you've got to do the whole lot
  3071. again, starting at #5EFD. The byte there will be decrypted to
  3072. either #3E or #ED - you'll have to guess which decrypting value
  3073. to use. For Tapper, the start is #5F2B, the length is #1BF, and
  3074. the second decrypter value is #AB.
  3075.  When you've done that, you'll either get the complete loading
  3076. system or another decrypter. If you've got the loading system,
  3077. then reload the BASIC loader, and do a stack trace to find out
  3078. where it should go. You should have no problems with the loader.
  3079.  If you've got another decrpyter, go along five bytes and find a
  3080. LD DE,(XXXX). Add #2E to this value, and that's where you move it
  3081. to. The length is the same as that for the second decrypter. The
  3082. decrypter itself can be cracked by changing a JP Z in the code
  3083. about forty bytes later (the value of this is the start of the
  3084. turboloader), but the decrypter itself uses a byte which is
  3085. worked out by adding all the memory together in the loading
  3086. system. Since we've got an exact copy of this system elsewhere in
  3087. memory, just change the value of XXXX in the aforementioned LD
  3088. DE,(XXXX), and then JP to the start of the decrypter.
  3089.  If the first decrypting value you used was #CB, then you can
  3090. just change the JP in the turboloader to your POKEs.
  3091.  
  3092.  If the value was #CD, then you'll need to know about the
  3093. Standard Speedlock patch. Somewhere in the loading system there
  3094. will be the two bytes ED 53 [LD DE,(XXXX)]. Change the XXXX to
  3095. the address of your POKEs (#5BA0 is normally safe), and end your
  3096. POKEs with a JP to the value you overwrote. You'll have to use
  3097. this patch for the later Speedlocks as well.
  3098.  
  3099.  There was a Speedlock Type 1 MultiPOKE in YS#79. RUN the
  3100. program, press BREAK and disassemble address #5B00 to find out
  3101. what to do in your own hacks.
  3102.  
  3103.  Type 2 Speedlocks feature a very easy BASIC loader, and one big
  3104. block of code, which has six short decrypters and a complex
  3105. moving routine. The decrypters are all easy peasy, just move them
  3106. to somewhere else in memory (such as #5B00), bung a RET on the
  3107. end, and CALL the decrypter from there (but watch out for the
  3108. third decrypter, which checks for a Multiface and crashes if it
  3109. finds it. The moving routine fiddles about with the loader.
  3110. Search for 31, which means LD SP,XXXX. Hopefully, you'll find a
  3111. LD SP,#0000, with perhaps a DI right before it. Write down the
  3112. address and run the moving routine (you may have to restart the
  3113. tape, because some of the moving routines insist on a signal
  3114. coming into the tape recorder). Use a stack trace to find out
  3115. where the code has gone to. Now you can move all the code from
  3116. the moving routine to the end of the machine code block to where
  3117. it should be, given that you know where the LD SP,#0000 goes to.
  3118. Once moved, patch the loader in the same way as the first
  3119. Speedlock.
  3120.  
  3121.  Type 3s have just one long BASIC loader, with about 144
  3122. decrypters, but that's nothing to worry about. *Hack the BASIC
  3123. loader, and have a look at the first bit of code which moves the
  3124. rest of the code into the right place (you can then use a
  3125. headerless loader to load this into the right place in memory).
  3126. The tricky bit is changing a byte in memory so a CALL to the
  3127. loading system at the very top of the code is changed to a CALL
  3128. somewhere else once all the decrypters have been run. The only
  3129. way you can do this is to change the address of the hi byte of
  3130. this CALL to something else, and RUN the huge load of the
  3131. decrypters. The computer will crash if you have a Multiface
  3132. attached, but only after everything's been decrypted, so then
  3133. look and see what the CALL's been changed to. If it's suitable,
  3134. remember the patch, position your hack around this, change the
  3135. CALL to what it should be,and put in the usual Speedlock patch.
  3136. Look at the start address in the turboloader. This address will
  3137. be overwritten by a decrypter once loading finishes. This
  3138. decrypter is nothing special, so just crack it as usual, and
  3139. watch out for the game moving around.
  3140.  Jon North's Pokerama Tapes usually have a Speedlock Type 3 crack
  3141. on it - load up the Pokerama, choose your POKE, then do a stack
  3142. trace to find it and have a look at it.
  3143.  
  3144. Part 7 - Epilogue
  3145.  
  3146.  Well folks, I'm sorry to have to break this to you, but I've
  3147. just about told everything you should ever need to know to crack
  3148. every protection system under the sun. So I'll just say some
  3149. final words and credits, and then sign off, okay?
  3150.  
  3151.  The idea of this book, its production and its writing were done
  3152. entirely by Richard Swann, from February to June 1992.
  3153.  
  3154.  Some suggestions and tips came from two people to whom this book
  3155. is dedicated, Matt Corby from "down-the-road", and Niall "Mr
  3156. Incredibly Technical" Daley. Thanks, guys!
  3157.  
  3158.  Thanks to YS for putting disassemblers and the like on recent
  3159. covertapes; it saved me the trouble of writing one!
  3160.  
  3161.  Thanks to Jon North for some of the info on hacking he gave to
  3162. me on disk recently - much appreciated, mate.
  3163.  
  3164.  Thanks for YOU for buying this. There aren't many Speccy hackers
  3165. around right now, so we need to make the numbers up. Good luck!
  3166.  
  3167.  What's that? "I don't understand this bit at all!" I hear you
  3168. say. Well, send me any queries that you may have about this book,
  3169. stating exactly what the problem is, along with an SAE (very
  3170. important that), and I'll do my best to reply to them. DON'T
  3171. write to me asking me to hack a whole list of games for you - I
  3172. just haven't got the time. However, I've got a big book of
  3173. Multiface POKEs which you can obtain for £1.50 and an A4 SAE if
  3174. you want it, so that might come in handy.
  3175.  
  3176.  Thought for the year: Seven years ago, Spectrum and Commodore
  3177. owners were at each other's throats. Spectrum owners would vow
  3178. never to have anything to do with Commodore. Then why do I hear
  3179. of so many Spectrum owners that have upgraded to a Commodore
  3180. Amiga? Personally, I can't stand the Amiga's operating system -
  3181. it's terrible!
  3182.  
  3183.  Well, that seems to be about it, so I'll just leave you know in
  3184. the hands of a glossary of terms. Happy hacking!
  3185.  
  3186. RICHARD SWANN - June 1992
  3187.  
  3188. GLOSSARY
  3189.  
  3190. Breakpoint - an instruction put in by a disassembler which will
  3191. return control to it when it is executed. Also something to do
  3192. with tennis.
  3193.  
  3194. Crack/cracking - writing a routine or executing some code which
  3195. will get round some element of a protection system, enabling the
  3196. user to put a POKE into the game.
  3197.  
  3198. Crash - an undesired effect which the programmer or user did not
  3199. intend to happen. Classic example is the computer resetting
  3200. itself to give the old "(C) 1982 Sinclair etc.etc.", or a whole
  3201. load of flashing squares. Also a now defunct computer magazine.
  3202.  
  3203. Decrypter - a short program contained in a protection system
  3204. which, when run will change garbage into runnable code. You need
  3205. to crack a decrypter to write a hack for it.
  3206.  
  3207. Endless loop - the Multiface equivalent of a breakpoint, put in
  3208. hacking a protection system or doing a stack trace. The computer
  3209. will keep executing the same code over and over again,
  3210. indefinitely, unless the Multiface button is pressed. See also
  3211. endless loop (ho ho ho!)
  3212.  
  3213. Garbage - A block of machine code which does not make sense to a
  3214. human. The computer will attempt to process it, but will almost
  3215. certainly crash. Also what the dustmen collect in America.
  3216.  
  3217. Hack - a self-standing program which when run will load a game
  3218. and activate certain cheats. Also the act of getting round a
  3219. protection system. (See also crack). Also a lot of anonymous
  3220. people from Scotland.
  3221.  
  3222. Headerless loader - a loader which does not contain the first
  3223. "header part" of a file specifying it's name, length etc, but
  3224. has it ready built into memory. This makes the program harder to
  3225. hack.
  3226.  
  3227. Interrupt - small program which occurs every 150 of a second,
  3228. regardless of what the computer is doing.
  3229.  
  3230. Loader - any program which reads a file off tape into memory, and
  3231. executes it. This may consist of simple BASIC commands, a
  3232. headerless loader, a turboloader or even a protection system.
  3233.  
  3234. Operating system - this the built in program into the computer to
  3235. deal with all the basic things like reading the keyboard and
  3236. loading software. This is BASIC in the case of the Spectrum. Most
  3237. protection systems deliberately confuse the operating system or
  3238. lock you out of it.
  3239.  
  3240. Patch - replacing a bit of code whith something designed to hack
  3241. it. This patch may consist of a jump elsewhere in memory, or a
  3242. breakpoint. Also something that pirates wear on one eye.
  3243.  
  3244. POKE - the process in which a single byte of memory is changed.
  3245. Originally, games were hacked by one or two POKEs.
  3246.  
  3247. Protection system - A block of code which tags on the front of a
  3248. game's loader and prevents anyone from accessing the code it is
  3249. protecting. At least, that's what it's supposed to do!
  3250.  
  3251. Trace - looking through a block of code with the aim of finding
  3252. something specific (such as an infinite lives POKE). This may be
  3253. forwards, backwards, interrupt or stack trace.
  3254.  
  3255. Turboloader - a loader which loads in a file off tape at a faster
  3256. speed than usual. This speeds up loading. The turboloader may be
  3257. hidden by a protection system.
  3258.  
  3259. THE END
  3260.  
  3261. [C] 1992 NSA Publications. No part of this book may be copied,
  3262. otherwise I'll send the Mafia round. Okay?
  3263.